Skip to content

Commit 505e72b

Browse files
committed
Extract record geo tests to own controller
1 parent d970799 commit 505e72b

File tree

2 files changed

+51
-50
lines changed

2 files changed

+51
-50
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
require 'test_helper'
2+
3+
class RecordControllerGeoTest < ActionDispatch::IntegrationTest
4+
test 'no access button displays if GDT feature is disabled' do
5+
gis_record_id = 'gismit:CAMBRIDGEMEMPOLES09'
6+
VCR.use_cassette('gis record mit free',
7+
allow_playback_repeats: true,
8+
match_requests_on: %i[method uri body]) do
9+
get "/record/#{gis_record_id}"
10+
assert_select 'a.access-button', count: 0
11+
end
12+
end
13+
14+
test 'access button displays for freely accessible data' do
15+
ClimateControl.modify FEATURE_GEODATA: 'true' do
16+
gis_record_id = 'gismit:CAMBRIDGEMEMPOLES09'
17+
VCR.use_cassette('gis record mit free',
18+
allow_playback_repeats: true,
19+
match_requests_on: %i[method uri body]) do
20+
get "/record/#{gis_record_id}"
21+
assert_select 'a.access-button', text: 'Download geodata files',
22+
href: 'https://cdn.dev1.mitlibrary.net/geo/public/CAMBRIDGEMEMPOLES09.zip'
23+
end
24+
end
25+
end
26+
27+
test 'access button displays for data requiring MIT auth' do
28+
ClimateControl.modify FEATURE_GEODATA: 'true' do
29+
gis_record_id = 'gismit:us_ma_boston_g47parcels_2018'
30+
VCR.use_cassette('gis record mit auth',
31+
allow_playback_repeats: true,
32+
match_requests_on: %i[method uri body]) do
33+
get "/record/#{gis_record_id}"
34+
assert_select 'a.access-button', text: 'Download geodata files MIT authentication',
35+
href: 'https://cdn.dev1.mitlibrary.net/geo/restricted/us_ma_boston_g47parcels_2018.zip'
36+
end
37+
end
38+
end
39+
40+
test 'access button displays for non-MIT GIS records' do
41+
ClimateControl.modify FEATURE_GEODATA: 'true' do
42+
gis_record_id = 'gisogm:edu.stanford.purl:be6ef8cd8ac5'
43+
VCR.use_cassette('gis record elsewhere',
44+
allow_playback_repeats: true,
45+
match_requests_on: %i[method uri body]) do
46+
get "/record/#{gis_record_id}"
47+
assert_select 'a.access-button', text: 'View Stanford record', href: 'https://purl.stanford.edu/kv971cf1984'
48+
end
49+
end
50+
end
51+
end

test/controllers/record_controller_test.rb

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -36,54 +36,4 @@ class RecordControllerTest < ActionDispatch::IntegrationTest
3636
assert_select 'main', /(.*)#{message}(.*)/
3737
end
3838
end
39-
40-
class RecordControllerGeoTest < RecordControllerTest
41-
test 'no access button displays if GDT feature is disabled' do
42-
gis_record_id = 'gismit:CAMBRIDGEMEMPOLES09'
43-
VCR.use_cassette('gis record mit free',
44-
allow_playback_repeats: true,
45-
match_requests_on: %i[method uri body]) do
46-
get "/record/#{gis_record_id}"
47-
assert_select 'a.access-button', count: 0
48-
end
49-
end
50-
51-
test 'access button displays for freely accessible data' do
52-
ClimateControl.modify FEATURE_GEODATA: 'true' do
53-
gis_record_id = 'gismit:CAMBRIDGEMEMPOLES09'
54-
VCR.use_cassette('gis record mit free',
55-
allow_playback_repeats: true,
56-
match_requests_on: %i[method uri body]) do
57-
get "/record/#{gis_record_id}"
58-
assert_select 'a.access-button', text: 'Download geodata files',
59-
href: 'https://cdn.dev1.mitlibrary.net/geo/public/CAMBRIDGEMEMPOLES09.zip'
60-
end
61-
end
62-
end
63-
64-
test 'access button displays for data requiring MIT auth' do
65-
ClimateControl.modify FEATURE_GEODATA: 'true' do
66-
gis_record_id = 'gismit:us_ma_boston_g47parcels_2018'
67-
VCR.use_cassette('gis record mit auth',
68-
allow_playback_repeats: true,
69-
match_requests_on: %i[method uri body]) do
70-
get "/record/#{gis_record_id}"
71-
assert_select 'a.access-button', text: 'Download geodata files MIT authentication',
72-
href: 'https://cdn.dev1.mitlibrary.net/geo/restricted/us_ma_boston_g47parcels_2018.zip'
73-
end
74-
end
75-
end
76-
77-
test 'access button displays for non-MIT GIS records' do
78-
ClimateControl.modify FEATURE_GEODATA: 'true' do
79-
gis_record_id = 'gisogm:edu.stanford.purl:be6ef8cd8ac5'
80-
VCR.use_cassette('gis record elsewhere',
81-
allow_playback_repeats: true,
82-
match_requests_on: %i[method uri body]) do
83-
get "/record/#{gis_record_id}"
84-
assert_select 'a.access-button', text: 'View Stanford record', href: 'https://purl.stanford.edu/kv971cf1984'
85-
end
86-
end
87-
end
88-
end
8939
end

0 commit comments

Comments
 (0)