|
6 | 6 | before { sign_in(user) } |
7 | 7 |
|
8 | 8 | context "contributor" do |
9 | | - it "can access the Topics tab" do |
10 | | - get "/topics" |
11 | | - expect(response).to be_successful |
| 9 | + context "Region-related actions" do |
| 10 | + let!(:region) { create(:region) } |
| 11 | + |
| 12 | + it "cannot access the Regions index" do |
| 13 | + expect(get "/regions").to redirect_to(topics_path) |
| 14 | + end |
| 15 | + |
| 16 | + it "cannot access Region show page" do |
| 17 | + expect(get "/regions/#{region.id}").to redirect_to(topics_path) |
| 18 | + end |
| 19 | + |
| 20 | + it "cannot access Region new page" do |
| 21 | + expect(get "/regions/new").to redirect_to(topics_path) |
| 22 | + end |
| 23 | + |
| 24 | + it "cannot make a Region create request" do |
| 25 | + expect { post "/regions", params: { region: { name: "A new Region" } } }.not_to change { Region.count } |
| 26 | + expect(response).to redirect_to(topics_path) |
| 27 | + end |
| 28 | + |
| 29 | + it "cannot access Region edit page" do |
| 30 | + expect(get "/regions/#{region.id}/edit").to redirect_to(topics_path) |
| 31 | + end |
| 32 | + |
| 33 | + it "cannot make a Region update request" do |
| 34 | + expect { put "/regions/#{region.id}", params: { region: { name: "Updated Region" } } }.not_to change { region.reload.updated_at } |
| 35 | + expect(response).to redirect_to(topics_path) |
| 36 | + end |
| 37 | + |
| 38 | + it "cannot make a Region delete request" do |
| 39 | + expect { delete "/regions/#{region.id}" }.not_to change { Region.count } |
| 40 | + expect(response).to redirect_to(topics_path) |
| 41 | + end |
12 | 42 | end |
13 | 43 |
|
14 | | - it "cannot access the Regions tab" do |
15 | | - get "/regions" |
16 | | - expect(response).to redirect_to(topics_path) |
| 44 | + context "Provider-related actions" do |
| 45 | + let!(:provider) { create(:provider) } |
| 46 | + |
| 47 | + it "cannot access the Providers index" do |
| 48 | + expect(get "/providers").to redirect_to(topics_path) |
| 49 | + end |
| 50 | + |
| 51 | + it "cannot access Provider show page" do |
| 52 | + expect(get "/providers/#{provider.id}").to redirect_to(topics_path) |
| 53 | + end |
| 54 | + |
| 55 | + it "cannot access Provider new page" do |
| 56 | + expect(get "/providers/new").to redirect_to(topics_path) |
| 57 | + end |
| 58 | + |
| 59 | + it "cannot make a Provider create request" do |
| 60 | + expect { post "/providers", params: { provider: { name: "A new Provider", provider_type: "provider" } } }.not_to change { Provider.count } |
| 61 | + expect(response).to redirect_to(topics_path) |
| 62 | + end |
| 63 | + |
| 64 | + it "cannot access Provider edit page" do |
| 65 | + expect(get "/providers/#{provider.id}/edit").to redirect_to(topics_path) |
| 66 | + end |
| 67 | + |
| 68 | + it "cannot make a Provider update request" do |
| 69 | + expect { put "/providers/#{provider.id}", params: { provider: { name: "Updated Provider" } } }.not_to change { provider.reload.updated_at } |
| 70 | + expect(response).to redirect_to(topics_path) |
| 71 | + end |
| 72 | + |
| 73 | + it "cannot make a Provider delete request" do |
| 74 | + expect { delete "/providers/#{provider.id}" }.not_to change { Provider.count } |
| 75 | + expect(response).to redirect_to(topics_path) |
| 76 | + end |
17 | 77 | end |
18 | 78 |
|
19 | | - it "cannot access the Providers tab" do |
20 | | - get "/providers" |
21 | | - expect(response).to redirect_to(topics_path) |
| 79 | + context "Language-related actions" do |
| 80 | + let!(:language) { create(:language) } |
| 81 | + |
| 82 | + it "cannot access the Languages index" do |
| 83 | + expect(get "/languages").to redirect_to(topics_path) |
| 84 | + end |
| 85 | + |
| 86 | + it "cannot access Language new page" do |
| 87 | + expect(get "/languages/new").to redirect_to(topics_path) |
| 88 | + end |
| 89 | + |
| 90 | + it "cannot make a Language create request" do |
| 91 | + expect { post "/languages", params: { language: { name: "A new Language", language_type: "language" } } }.not_to change { Language.count } |
| 92 | + expect(response).to redirect_to(topics_path) |
| 93 | + end |
| 94 | + |
| 95 | + it "cannot access Language edit page" do |
| 96 | + expect(get "/languages/#{language.id}/edit").to redirect_to(topics_path) |
| 97 | + end |
| 98 | + |
| 99 | + it "cannot make a Language update request" do |
| 100 | + expect { put "/languages/#{language.id}", params: { language: { name: "Updated Language" } } }.not_to change { language.reload.updated_at } |
| 101 | + expect(response).to redirect_to(topics_path) |
| 102 | + end |
22 | 103 | end |
23 | 104 |
|
24 | | - it "cannot access the Languages tab" do |
25 | | - get "/languages" |
26 | | - expect(response).to redirect_to(topics_path) |
| 105 | + context "Tag-related actions" do |
| 106 | + let!(:tag) { create(:tag) } |
| 107 | + |
| 108 | + it "cannot access the Tags index" do |
| 109 | + expect(get "/tags").to redirect_to(topics_path) |
| 110 | + end |
| 111 | + |
| 112 | + it "cannot access Tag show page" do |
| 113 | + expect(get "/tags/#{tag.id}").to redirect_to(topics_path) |
| 114 | + end |
| 115 | + |
| 116 | + it "cannot access Tag edit page" do |
| 117 | + expect(get "/tags/#{tag.id}/edit").to redirect_to(topics_path) |
| 118 | + end |
| 119 | + |
| 120 | + it "cannot make a Tag update request" do |
| 121 | + expect { put "/tags/#{tag.id}", params: { tag: { name: "Updated Tag" } } }.not_to change { tag.reload.updated_at } |
| 122 | + expect(response).to redirect_to(topics_path) |
| 123 | + end |
| 124 | + |
| 125 | + it "cannot make a Tag delete request" do |
| 126 | + expect(delete "/tags/#{tag.id}").to redirect_to(topics_path) |
| 127 | + end |
27 | 128 | end |
28 | 129 |
|
29 | | - it "cannot access the Users tab" do |
30 | | - get "/users" |
31 | | - expect(response).to redirect_to(topics_path) |
| 130 | + context "User-related actions" do |
| 131 | + let!(:user) { create(:user) } |
| 132 | + |
| 133 | + it "cannot access the Users index" do |
| 134 | + expect(get "/users").to redirect_to(topics_path) |
| 135 | + end |
| 136 | + |
| 137 | + it "cannot access User new page" do |
| 138 | + expect(get "/users/new").to redirect_to(topics_path) |
| 139 | + end |
| 140 | + |
| 141 | + it "cannot make a User create request" do |
| 142 | + provider = create(:provider) |
| 143 | + expect { post "/users", params: { user: { email: Faker::Internet.email, password: "password123", provider_ids: [ provider.id ] } } } |
| 144 | + .not_to change { User.count } |
| 145 | + expect(response).to redirect_to(topics_path) |
| 146 | + end |
| 147 | + |
| 148 | + it "cannot access User edit page" do |
| 149 | + expect(get "/users/#{user.id}/edit").to redirect_to(topics_path) |
| 150 | + end |
| 151 | + |
| 152 | + it "cannot make a User update request" do |
| 153 | + expect { put "/users/#{user.id}", params: { user: { is_admin: "true" } } }.not_to change { user.reload.updated_at } |
| 154 | + expect(response).to redirect_to(topics_path) |
| 155 | + end |
| 156 | + |
| 157 | + it "cannot make a User delete request" do |
| 158 | + expect { delete "/users/#{user.id}" }.not_to change { User.count } |
| 159 | + expect(response).to redirect_to(topics_path) |
| 160 | + end |
| 161 | + end |
| 162 | + |
| 163 | + context "Import Reports-related actions" do |
| 164 | + let!(:import_report) { ImportReport.create } |
| 165 | + |
| 166 | + it "cannot access the ImportReport index" do |
| 167 | + expect(get "/import_reports").to redirect_to(topics_path) |
| 168 | + end |
| 169 | + |
| 170 | + it "cannot access ImportReport show page" do |
| 171 | + expect(get "/import_reports/#{import_report.id}").to redirect_to(topics_path) |
| 172 | + end |
32 | 173 | end |
33 | 174 | end |
34 | 175 |
|
|
40 | 181 | expect(response).to be_successful |
41 | 182 | end |
42 | 183 |
|
43 | | - it "cannot access the Regions tab" do |
| 184 | + it "can access the Regions tab" do |
44 | 185 | get "/regions" |
45 | 186 | expect(response).to be_successful |
46 | 187 | end |
47 | 188 |
|
48 | | - it "cannot access the Providers tab" do |
| 189 | + it "can access the Providers tab" do |
49 | 190 | get "/providers" |
50 | 191 | expect(response).to be_successful |
51 | 192 | end |
52 | 193 |
|
53 | | - it "cannot access the Languages tab" do |
| 194 | + it "can access the Languages tab" do |
54 | 195 | get "/languages" |
55 | 196 | expect(response).to be_successful |
56 | 197 | end |
57 | 198 |
|
58 | | - it "cannot access the Users tab" do |
| 199 | + it "can access the Users tab" do |
59 | 200 | get "/users" |
60 | 201 | expect(response).to be_successful |
61 | 202 | end |
|
0 commit comments