Skip to content

Commit

Permalink
Tidy up reloads in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yndajas committed Aug 9, 2024
1 parent 9360f2b commit e25c599
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
16 changes: 4 additions & 12 deletions test/controllers/account/permissions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,12 @@ class Account::PermissionsControllerTest < ActionController::TestCase
},
)

current_user.reload

assert_same_elements [
updating_application_new_permission,
other_application_old_permission,
updating_application.signin_permission,
other_application.signin_permission,
], current_user.supported_permissions
], current_user.reload.supported_permissions
end

should "prevent permissions that are not grantable from the UI being added or removed" do
Expand All @@ -345,13 +343,11 @@ class Account::PermissionsControllerTest < ActionController::TestCase

patch :update, params: { application_id: application, application: { supported_permission_ids: [new_grantable_permission.id, new_non_grantable_permission.id] } }

current_user.reload

assert_same_elements [
old_non_grantable_permission,
new_grantable_permission,
application.signin_permission,
], current_user.supported_permissions
], current_user.reload.supported_permissions
end

should "assign the application id to the application_id flash" do
Expand Down Expand Up @@ -394,9 +390,7 @@ class Account::PermissionsControllerTest < ActionController::TestCase
# assert redirected to apps page
assert_redirected_to account_applications_path

@current_user.reload

assert_equal [*@old_permissions, @new_permission, @application.signin_permission], @current_user.supported_permissions
assert_equal [*@old_permissions, @new_permission, @application.signin_permission], @current_user.reload.supported_permissions
end

context "when the add_more param is 'true'" do
Expand All @@ -405,9 +399,7 @@ class Account::PermissionsControllerTest < ActionController::TestCase

assert_redirected_to edit_account_application_permissions_path(@application)

@current_user.reload

assert_equal [*@old_permissions, @new_permission, @application.signin_permission], @current_user.supported_permissions
assert_equal [*@old_permissions, @new_permission, @application.signin_permission], @current_user.reload.supported_permissions
end
end
end
Expand Down
16 changes: 4 additions & 12 deletions test/controllers/users/permissions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,12 @@ class Users::PermissionsControllerTest < ActionController::TestCase
},
)

user.reload

assert_same_elements [
updating_application_new_permission,
other_application_old_permission,
updating_application.signin_permission,
other_application.signin_permission,
], user.supported_permissions
], user.reload.supported_permissions
end

should "prevent permissions that are not grantable from the UI being added or removed" do
Expand Down Expand Up @@ -422,13 +420,11 @@ class Users::PermissionsControllerTest < ActionController::TestCase

patch :update, params: { user_id: user, application_id: application, application: { supported_permission_ids: [new_grantable_permission.id, new_non_grantable_permission.id] } }

user.reload

assert_same_elements [
old_non_grantable_permission,
new_grantable_permission,
application.signin_permission,
], user.supported_permissions
], user.reload.supported_permissions
end

should "assign the application id to the application_id flash" do
Expand Down Expand Up @@ -495,9 +491,7 @@ class Users::PermissionsControllerTest < ActionController::TestCase

assert_redirected_to user_applications_path(@user)

@current_user.reload

assert_equal [*@old_permissions, @new_permission, @application.signin_permission], @user.supported_permissions
assert_equal [*@old_permissions, @new_permission, @application.signin_permission], @user.reload.supported_permissions
end

context "when the add_more param is 'true'" do
Expand All @@ -517,9 +511,7 @@ class Users::PermissionsControllerTest < ActionController::TestCase

assert_redirected_to edit_user_application_permissions_path(@user, @application)

@current_user.reload

assert_equal [*@old_permissions, @new_permission, @application.signin_permission], @user.supported_permissions
assert_equal [*@old_permissions, @new_permission, @application.signin_permission], @user.reload.supported_permissions
end
end
end
Expand Down

0 comments on commit e25c599

Please sign in to comment.