Skip to content

Commit f120fe9

Browse files
authored
Add link to Mission Control for Admins (#409)
2 parents 5522856 + 1a12c22 commit f120fe9

File tree

3 files changed

+81
-38
lines changed

3 files changed

+81
-38
lines changed

app/views/layouts/_sidebar.html.erb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@
9595
<span>Import Reports</span>
9696
<% end %>
9797
</li>
98+
99+
<li class="sidebar-item">
100+
<%= link_to "/jobs", class: 'sidebar-link', target: "_blank" do %>
101+
<i class="bi bi-window-stack"></i>
102+
<span>Jobs</span>
103+
<% end %>
104+
</li>
98105
<% end %>
99106
</ul>
100107
</div>

spec/requests/authorizations_spec.rb

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,75 @@
11
require "rails_helper"
22

33
RSpec.describe "Authorizations", type: :request do
4-
let(:user) { create(:user) }
4+
context "not authenticated" do
5+
context "when trying to access the Regions index" do
6+
it "redirects to the login page" do
7+
get "/regions"
8+
expect(response).to redirect_to("/session/new")
9+
expect(session[:return_to_after_authenticating]).to eq("/regions")
10+
end
11+
end
12+
13+
context "when trying to access the Providers index" do
14+
it "redirects to the login page" do
15+
get "/providers"
16+
expect(response).to redirect_to("/session/new")
17+
expect(session[:return_to_after_authenticating]).to eq("/providers")
18+
end
19+
end
20+
21+
context "when trying to access the Languages index" do
22+
it "redirects to the login page" do
23+
get "/languages"
24+
expect(response).to redirect_to("/session/new")
25+
expect(session[:return_to_after_authenticating]).to eq("/languages")
26+
end
27+
end
28+
29+
context "when trying to access the Tags index" do
30+
it "redirects to the login page" do
31+
get "/tags"
32+
expect(response).to redirect_to("/session/new")
33+
expect(session[:return_to_after_authenticating]).to eq("/tags")
34+
end
35+
end
36+
37+
context "when trying to access the Users index" do
38+
it "redirects to the login page" do
39+
get "/users"
40+
expect(response).to redirect_to("/session/new")
41+
expect(session[:return_to_after_authenticating]).to eq("/users")
42+
end
43+
end
544

6-
before { sign_in(user) }
45+
context "when trying to access the Import Reports index" do
46+
it "redirects to the login page" do
47+
get "/import_reports"
48+
expect(response).to redirect_to("/session/new")
49+
expect(session[:return_to_after_authenticating]).to eq("/import_reports")
50+
end
51+
end
52+
53+
context "when trying to access the Jobs interface" do
54+
it "redirects to the login page" do
55+
get "/jobs"
56+
expect(response).to redirect_to("/session/new")
57+
expect(session[:return_to_after_authenticating]).to eq("/jobs/")
58+
end
59+
end
60+
end
761

862
context "contributor" do
63+
let(:user) { create(:user) }
64+
65+
before { sign_in(user) }
66+
67+
it "cannot access the Jobs interface" do
68+
get "/jobs"
69+
expect(response).to have_http_status(:forbidden)
70+
expect(response.body).to include("Access denied")
71+
end
72+
973
context "Region-related actions" do
1074
let!(:region) { create(:region) }
1175

@@ -174,7 +238,9 @@
174238
end
175239

176240
context "administrator" do
177-
before { user.update(is_admin: true) }
241+
let(:admin) { create(:user, :admin) }
242+
243+
before { sign_in(admin) }
178244

179245
it "can access the Topics tab" do
180246
get "/topics"
@@ -200,5 +266,10 @@
200266
get "/users"
201267
expect(response).to be_successful
202268
end
269+
270+
it "can access the Jobs interface" do
271+
get "/jobs"
272+
expect(response).to be_successful
273+
end
203274
end
204275
end

spec/requests/jobs_spec.rb

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)