@@ -111,4 +111,84 @@ class ResultsHelperTest < ActionView::TestCase
111111 assert_not article? ( nil )
112112 assert_not article? ( '' )
113113 end
114+
115+ test 'result_get? returns true when result has links' do
116+ assert result_get? ( { links : [ { 'kind' => 'PDF' , 'url' => 'https://example.com' } ] } )
117+ end
118+
119+ test 'result_get? returns true when result has availability' do
120+ assert result_get? ( { availability : 'Available' } )
121+ end
122+
123+ test 'result_get? returns true when ThirdIron enabled and result has doi' do
124+ ClimateControl . modify ( THIRDIRON_ID : '123' , THIRDIRON_KEY : 'abc' ) do
125+ assert result_get? ( { doi : '10.1234/test' } )
126+ end
127+ end
128+
129+ test 'result_get? returns true when ThirdIron enabled and result has pmid' do
130+ ClimateControl . modify ( THIRDIRON_ID : '123' , THIRDIRON_KEY : 'abc' ) do
131+ assert result_get? ( { pmid : '12345678' } )
132+ end
133+ end
134+
135+ test 'result_get? returns true when ThirdIron enabled and result is a journal with issn' do
136+ ClimateControl . modify ( THIRDIRON_ID : '123' , THIRDIRON_KEY : 'abc' ) do
137+ assert result_get? ( { format : 'Journal' , issn : '1234-5678' } )
138+ end
139+ end
140+
141+ test 'result_get? returns true when oa_always enabled and result is an article' do
142+ ClimateControl . modify ( FEATURE_OA_ALWAYS : 'true' ) do
143+ assert result_get? ( { format : 'Article' } )
144+ end
145+ end
146+
147+ test 'result_get? returns false when result has no fulfillment content' do
148+ ClimateControl . modify ( THIRDIRON_ID : nil , THIRDIRON_KEY : nil , FEATURE_OA_ALWAYS : nil ) do
149+ assert_not result_get? ( { } )
150+ assert_not result_get? ( { format : 'Book' } )
151+ end
152+ end
153+
154+ test 'result_get? returns false when ThirdIron disabled even with doi' do
155+ ClimateControl . modify ( THIRDIRON_ID : nil , THIRDIRON_KEY : nil ) do
156+ assert_not result_get? ( { doi : '10.1234/test' } )
157+ end
158+ end
159+
160+ test 'result_get? returns false when oa_always disabled and result has no links' do
161+ ClimateControl . modify ( FEATURE_OA_ALWAYS : nil , THIRDIRON_ID : nil , THIRDIRON_KEY : nil ) do
162+ assert_not result_get? ( { format : 'Article' } )
163+ end
164+ end
165+
166+ test 'result_get? returns false when result has only full record link and feature is disabled' do
167+ ClimateControl . modify ( FEATURE_RECORD_LINK : nil , THIRDIRON_ID : nil , THIRDIRON_KEY : nil , FEATURE_OA_ALWAYS : nil ) do
168+ assert_not result_get? ( { links : [ { 'kind' => 'Full Record' , 'url' => 'https://example.com' } ] } )
169+ end
170+ end
171+
172+ test 'result_get? returns true when result has only full record link and feature is enabled' do
173+ ClimateControl . modify ( FEATURE_RECORD_LINK : 'true' , THIRDIRON_ID : nil , THIRDIRON_KEY : nil , FEATURE_OA_ALWAYS : nil ) do
174+ assert result_get? ( { links : [ { 'kind' => 'Full Record' , 'url' => 'https://example.com' } ] } )
175+ end
176+ end
177+
178+ test 'result_get? returns true when result has PDF link even if record_link feature is disabled' do
179+ ClimateControl . modify ( FEATURE_RECORD_LINK : nil , THIRDIRON_ID : nil , THIRDIRON_KEY : nil , FEATURE_OA_ALWAYS : nil ) do
180+ assert result_get? ( { links : [ { 'kind' => 'PDF' , 'url' => 'https://example.com' } ] } )
181+ end
182+ end
183+
184+ test 'result_get? returns true when result has both full record and PDF links even if record_link feature is disabled' do
185+ ClimateControl . modify ( FEATURE_RECORD_LINK : nil , THIRDIRON_ID : nil , THIRDIRON_KEY : nil , FEATURE_OA_ALWAYS : nil ) do
186+ assert result_get? ( {
187+ links : [
188+ { 'kind' => 'Full Record' , 'url' => 'https://example.com' } ,
189+ { 'kind' => 'PDF' , 'url' => 'https://pdf.example.com' }
190+ ]
191+ } )
192+ end
193+ end
114194end
0 commit comments