-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
36 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= render(partial: "saved_scenarios/block_right_sub_options", locals: { saved_scenario: saved_scenario }) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,9 @@ | |
en: | ||
undo: Undo | ||
|
||
errors: | ||
sorry: Oops! We're sorry | ||
|
||
time: | ||
formats: | ||
short: "%-d %b %H:%M" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,8 @@ | |
let(:client) { Faraday.new(url: 'http://et.engine') } | ||
|
||
# Non logged-in users should always receive 404 not-found responses | ||
# when attempting to perform an action on SavedScenarioUsers. | ||
# when attempting to perform an action on SavedScenarioUsers. Because | ||
# of the current setup, some of these 404's are rendered as 302 redirects | ||
describe 'a non-logged in visitor' do | ||
let(:user) { FactoryBot.create(:user) } | ||
let!(:scenario_owner) do | ||
|
@@ -36,29 +37,29 @@ | |
it 'cannot view the list of users for a saved scenario' do | ||
get(:index, params: { saved_scenario_id: saved_scenario.id }) | ||
|
||
expect(response).to have_http_status(404) | ||
expect(response).to have_http_status(302) | ||
end | ||
|
||
it 'cannot add a new user to a scenario' do | ||
post(:create, format: :js, params: { | ||
post(:create, format: :turbo_stream, params: { | ||
saved_scenario_id: saved_scenario.id, | ||
user_email: '[email protected]', | ||
role_id: User::Roles.index_of(:scenario_owner) | ||
}) | ||
|
||
expect(response).to have_http_status(404) | ||
expect(response).to have_http_status(302) | ||
end | ||
|
||
it 'cannot update an existing scenario user' do | ||
put(:update, format: :js, params: { | ||
put(:update, format: :turbo_stream, params: { | ||
saved_scenario_id: saved_scenario.id, | ||
id: scenario_owner.id, | ||
saved_scenario_user: { | ||
role_id: User::Roles.index_of(:scenario_viewer) | ||
} | ||
}) | ||
|
||
expect(response).to have_http_status(404) | ||
expect(response).to have_http_status(302) | ||
end | ||
|
||
it 'cannot remove an existing scenario user' do | ||
|
@@ -67,7 +68,7 @@ | |
id: scenario_owner.id | ||
}) | ||
|
||
expect(response).to have_http_status(404) | ||
expect(response).to have_http_status(302) | ||
end | ||
end | ||
|
||
|
@@ -113,7 +114,7 @@ | |
end | ||
|
||
it 'is redirected when attempting to add a new user to a scenario' do | ||
post(:create, format: :js, params: { | ||
post(:create, format: :turbo_stream, params: { | ||
saved_scenario_id: saved_scenario.id, | ||
saved_scenario_user: { | ||
user_email: '[email protected]', | ||
|
@@ -125,7 +126,7 @@ | |
end | ||
|
||
it 'is redirected when attempting to update an existing scenario user' do | ||
put(:update, format: :js, params: { | ||
put(:update, format: :turbo_stream, params: { | ||
saved_scenario_id: saved_scenario.id, | ||
id: scenario_owner.id, | ||
saved_scenario_user: { | ||
|
@@ -158,7 +159,7 @@ | |
end | ||
|
||
it 'is redirected when attempting to add a new user to a scenario' do | ||
post(:create, format: :js, params: { | ||
post(:create, format: :turbo_stream, params: { | ||
saved_scenario_id: saved_scenario.id, | ||
saved_scenario_user: { | ||
user_email: '[email protected]', | ||
|
@@ -170,7 +171,7 @@ | |
end | ||
|
||
it 'is redirected when attempting to update an existing scenario user' do | ||
put(:update, format: :js, params: { | ||
put(:update, format: :turbo_stream, params: { | ||
saved_scenario_id: saved_scenario.id, | ||
id: scenario_owner.id, | ||
saved_scenario_user: { | ||
|
@@ -215,7 +216,7 @@ | |
end | ||
|
||
it 'can add a new user to a scenario' do | ||
post(:create, format: :js, params: { | ||
post(:create, format: :turbo_stream, params: { | ||
saved_scenario_id: saved_scenario.id, | ||
saved_scenario_user: { | ||
user_email: '[email protected]', | ||
|
@@ -240,7 +241,7 @@ | |
|
||
it 'can update the role' do | ||
# Promote viewer to owner! | ||
put(:update, format: :js, params: { | ||
put(:update, format: :turbo_stream, params: { | ||
saved_scenario_id: saved_scenario.id, | ||
id: scenario_viewer.id, | ||
saved_scenario_user: { | ||
|
@@ -256,7 +257,7 @@ | |
end | ||
|
||
it 'can remove the user' do | ||
delete(:destroy, format: :js, params: { | ||
delete(:destroy, format: :turbo_stream, params: { | ||
saved_scenario_id: saved_scenario.id, | ||
id: scenario_viewer.id | ||
}) | ||
|
@@ -268,7 +269,7 @@ | |
end | ||
|
||
it "cannot change its own role if it's the last owner" do | ||
put(:update, format: :js, params: { | ||
put(:update, format: :turbo_stream, params: { | ||
saved_scenario_id: saved_scenario.id, | ||
id: scenario_owner.id, | ||
saved_scenario_user: { | ||
|
@@ -297,14 +298,14 @@ | |
sign_in admin | ||
end | ||
|
||
it 'can not view the list of users for a saved scenario' do | ||
it 'can view the list of users for a saved scenario' do | ||
get(:index, params: { saved_scenario_id: saved_scenario.id }) | ||
|
||
expect(response).to have_http_status(404) | ||
expect(response).to have_http_status(200) | ||
end | ||
|
||
it 'can not add a new user to a scenario' do | ||
post(:create, format: :js, params: { | ||
it 'can add a new user to a scenario' do | ||
post(:create, format: :turbo_stream, params: { | ||
saved_scenario_id: saved_scenario.id, | ||
saved_scenario_user: { | ||
user_email: '[email protected]', | ||
|
@@ -314,7 +315,7 @@ | |
|
||
expect( | ||
saved_scenario.saved_scenario_users.where(user_email: '[email protected]').count | ||
).to be(0) | ||
).to be(1) | ||
end | ||
|
||
context 'when updating or removing an existing scenario user' do | ||
|
@@ -327,9 +328,9 @@ | |
) | ||
end | ||
|
||
it 'can not update the role' do | ||
it 'can update the role' do | ||
# Promote to owner! | ||
put(:update, format: :js, params: { | ||
put(:update, format: :turbo_stream, params: { | ||
saved_scenario_id: saved_scenario.id, | ||
id: scenario_viewer.id, | ||
saved_scenario_user: { | ||
|
@@ -340,19 +341,19 @@ | |
expect( | ||
saved_scenario.saved_scenario_users.find_by(user_email: '[email protected]')&.role_id | ||
).to eq( | ||
User::Roles.index_of(:scenario_viewer) | ||
User::Roles.index_of(:scenario_owner) | ||
) | ||
end | ||
|
||
it 'can not remove the user' do | ||
delete(:destroy, format: :js, params: { | ||
it 'can remove the user' do | ||
delete(:destroy, format: :turbo_stream, params: { | ||
saved_scenario_id: saved_scenario.id, | ||
id: scenario_viewer.id | ||
}) | ||
|
||
expect( | ||
saved_scenario.saved_scenario_users.where(user_email: '[email protected]').count | ||
).to be(1) | ||
).to be(0) | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters