-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3179 from alphagov/use-autocomplete-on-other-orga…
…nisation-fields Use autocomplete on other organisation fields
- Loading branch information
Showing
8 changed files
with
197 additions
and
49 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
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
This file was deleted.
Oops, something went wrong.
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,65 @@ | ||
require "test_helper" | ||
|
||
class Account::UpdatingOrganisationTest < ActionDispatch::IntegrationTest | ||
should "display read-only values for users who aren't GOVUK Admins" do | ||
organisation = create(:organisation, name: "Department for Viability") | ||
non_govuk_admin_user = create(:super_organisation_admin_user, organisation:) | ||
|
||
visit new_user_session_path | ||
signin_with non_govuk_admin_user | ||
|
||
visit edit_account_organisation_path | ||
|
||
assert has_text? "Department for Viability" | ||
assert_no_selector "select" | ||
end | ||
|
||
should "allow GOV.UK admin users to change their organisation" do | ||
current_organisation = create(:organisation, name: "Judiciary") | ||
user = create(:admin_user, organisation: current_organisation) | ||
|
||
create(:organisation, name: "Postage") | ||
|
||
visit new_user_session_path | ||
signin_with user | ||
|
||
visit edit_account_organisation_path | ||
|
||
select "Postage", from: "Organisation" | ||
click_button "Change organisation" | ||
|
||
assert_current_url account_path | ||
assert page.has_text? "Your organisation is now Postage" | ||
assert_equal "Postage", user.reload.organisation_name | ||
end | ||
|
||
context "with JavaScript enabled" do | ||
setup do | ||
use_javascript_driver | ||
end | ||
|
||
should "allow GOV.UK admin users to change their organisation" do | ||
current_organisation = create(:organisation, name: "Judiciary") | ||
user = create(:admin_user, organisation: current_organisation) | ||
|
||
create(:organisation, name: "Postage") | ||
|
||
visit new_user_session_path | ||
signin_with user | ||
|
||
visit edit_account_organisation_path | ||
|
||
autocomplete_helper = AutocompleteHelper.new | ||
autocomplete_helper.clear_selection | ||
autocomplete_helper.select_autocomplete_option("Postage") | ||
click_button "Change organisation" | ||
|
||
assert_current_url account_path | ||
assert page.has_text? "Your organisation is now Postage" | ||
|
||
visit edit_account_organisation_path | ||
|
||
assert_equal "Postage", user.reload.organisation_name | ||
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
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,65 @@ | ||
require "test_helper" | ||
|
||
class Users::UpdatingOrganisationTest < ActionDispatch::IntegrationTest | ||
should "display read-only values for users who aren't GOVUK Admins" do | ||
organisation = create(:organisation, name: "Department for Viability") | ||
user = create(:user, organisation:) | ||
non_govuk_admin_user = create(:super_organisation_admin_user, organisation:) | ||
|
||
visit new_user_session_path | ||
signin_with non_govuk_admin_user | ||
|
||
visit edit_user_path(user) | ||
|
||
assert has_text? "Department for Viability" | ||
assert_no_selector "a", text: "Change Organisation" | ||
end | ||
|
||
should "allow GOV.UK admin users to change their organisation" do | ||
current_organisation = create(:organisation, name: "Judiciary") | ||
user = create(:user, organisation: current_organisation) | ||
admin_user = create(:admin_user) | ||
|
||
create(:organisation, name: "Postage") | ||
|
||
visit new_user_session_path | ||
signin_with admin_user | ||
|
||
visit edit_user_organisation_path(user) | ||
|
||
select "Postage", from: "Organisation" | ||
click_button "Change organisation" | ||
|
||
assert_current_url edit_user_path(user) | ||
assert page.has_text? "Updated user #{user.email} successfully" | ||
assert_equal "Postage", user.reload.organisation_name | ||
end | ||
|
||
context "with JavaScript enabled" do | ||
setup do | ||
use_javascript_driver | ||
end | ||
|
||
should "allow GOV.UK admin users to change their organisation" do | ||
current_organisation = create(:organisation, name: "Judiciary") | ||
user = create(:admin_user, organisation: current_organisation) | ||
admin_user = create(:admin_user) | ||
|
||
create(:organisation, name: "Postage") | ||
|
||
visit new_user_session_path | ||
signin_with admin_user | ||
|
||
visit edit_user_organisation_path(user) | ||
|
||
autocomplete_helper = AutocompleteHelper.new | ||
autocomplete_helper.clear_selection | ||
autocomplete_helper.select_autocomplete_option("Postage") | ||
click_button "Change organisation" | ||
|
||
assert_current_url edit_user_path(user) | ||
assert page.has_text? "Updated user #{user.email} successfully" | ||
assert_equal "Postage", user.reload.organisation_name | ||
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