Skip to content

Commit

Permalink
Fix memberships test
Browse files Browse the repository at this point in the history
  • Loading branch information
martinemde committed Nov 21, 2024
1 parent 8972bcd commit 22eb5c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/controllers/organizations/members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def index
end

def create
membership = @organization.memberships.new(create_membership_params)
membership = @organization.memberships.build(create_membership_params)
authorize membership

if membership.save
Expand Down Expand Up @@ -57,10 +57,10 @@ def find_membership
end

def create_membership_params
params.require(:membership).permit(:user_id, :role)
params.permit(membership: %i[user_id role]).require(:membership)
end

def update_membership_params
params.require(:membership).permit(:role)
params.permit(membership: %i[role]).require(:membership)
end
end
6 changes: 4 additions & 2 deletions test/integration/organizations/members_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ class Organizations::MembersTest < ActionDispatch::IntegrationTest
post "/organizations/chaos/members", params: { membership: { user_id: maintainer.id, role: "maintainer" } }

assert_redirected_to organization_members_path(organization)
membership = organization.memberships.find_by(user_id: maintainer.id)

membership = organization.unconfirmed_memberships.find_by(user_id: maintainer.id)

assert membership
assert_predicate membership, :maintainer?
assert_predicete membership, :unconfirmed?
refute_predicate membership, :confirmed?
end

test "update should return Not Found org" do
Expand Down

0 comments on commit 22eb5c9

Please sign in to comment.