[deploy] Render the correct partial when editing an organization fails (#7765)
This commit is contained in:
parent
c47430cd20
commit
e28664c67f
2 changed files with 67 additions and 45 deletions
|
|
@ -41,6 +41,9 @@ class OrganizationsController < ApplicationController
|
|||
flash[:settings_notice] = "Your organization was successfully updated."
|
||||
redirect_to "/settings/organization"
|
||||
else
|
||||
@org_organization_memberships = @organization.organization_memberships.includes(:user)
|
||||
@organization_membership = OrganizationMembership.find_by(user_id: current_user.id, organization_id: @organization.id)
|
||||
|
||||
render template: "users/edit"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,51 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Organization setting page(/settings/organization)", type: :system, js: true do
|
||||
let(:user) { create(:user) }
|
||||
let(:organization) { create(:organization) }
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
it "user creates an organization" do
|
||||
visit "/settings/organization"
|
||||
fill_in_org_form
|
||||
click_button "Create Organization"
|
||||
|
||||
expect(page).to have_text("Your organization was successfully created and you are an admin.")
|
||||
end
|
||||
|
||||
it "promotes a member to an admin" do
|
||||
create(:organization_membership, user_id: user.id, organization_id: organization.id, type_of_user: "admin")
|
||||
user2 = create(:user, username: "newuser")
|
||||
create(:organization_membership, user_id: user2.id, organization_id: organization.id)
|
||||
visit "settings/organization"
|
||||
click_button("Make admin")
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
expect(page).to have_text("#{user2.name} is now an admin.")
|
||||
end
|
||||
|
||||
it "revokes an admin's privileges" do
|
||||
create(:organization_membership, user_id: user.id, organization_id: organization.id, type_of_user: "admin")
|
||||
user2 = create(:user, username: "newuser")
|
||||
create(:organization_membership, user_id: user2.id, organization_id: organization.id, type_of_user: "admin")
|
||||
visit "settings/organization"
|
||||
click_button("Revoke admin status")
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
expect(page).to have_text("#{user2.name} is no longer an admin.")
|
||||
end
|
||||
|
||||
it "remove user from organization" do
|
||||
create(:organization_membership, user_id: user.id, organization_id: organization.id, type_of_user: "admin")
|
||||
user2 = create(:user, username: "newuser")
|
||||
create(:organization_membership, user_id: user2.id, organization_id: organization.id)
|
||||
visit "settings/organization"
|
||||
click_button("Remove from org")
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
expect(page).to have_text("#{user2.name} is no longer part of your organization.")
|
||||
end
|
||||
|
||||
def fill_in_org_form
|
||||
fill_in "organization[name]", with: "Organization Name"
|
||||
fill_in "organization[slug]", with: "Organization"
|
||||
|
|
@ -59,4 +14,68 @@ RSpec.describe "Organization setting page(/settings/organization)", type: :syste
|
|||
fill_in "organization[summary]", with: "Summary"
|
||||
fill_in "organization[proof]", with: "Proof"
|
||||
end
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:user2) { create(:user, username: "newuser") }
|
||||
let(:organization) { create(:organization) }
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
def join_org(user, organization, type_of_user)
|
||||
create(
|
||||
:organization_membership,
|
||||
user: user,
|
||||
organization: organization,
|
||||
type_of_user: type_of_user,
|
||||
)
|
||||
end
|
||||
|
||||
it "user creates an organization" do
|
||||
visit "/settings/organization"
|
||||
fill_in_org_form
|
||||
click_button "Create Organization"
|
||||
|
||||
expect(page).to have_text("Your organization was successfully created and you are an admin.")
|
||||
end
|
||||
|
||||
it "promotes a member to an admin" do
|
||||
join_org(user, organization, :admin)
|
||||
join_org(user2, organization, :member)
|
||||
|
||||
visit "settings/organization"
|
||||
click_button("Make admin")
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
expect(page).to have_text("#{user2.name} is now an admin.")
|
||||
end
|
||||
|
||||
it "revokes an admin's privileges" do
|
||||
join_org(user, organization, :admin)
|
||||
join_org(user2, organization, :admin)
|
||||
|
||||
visit "settings/organization"
|
||||
click_button("Revoke admin status")
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
expect(page).to have_text("#{user2.name} is no longer an admin.")
|
||||
end
|
||||
|
||||
it "remove user from organization" do
|
||||
join_org(user, organization, :admin)
|
||||
join_org(user2, organization, :member)
|
||||
|
||||
visit "settings/organization"
|
||||
click_button("Remove from org")
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
expect(page).to have_text("#{user2.name} is no longer part of your organization.")
|
||||
end
|
||||
|
||||
it "uses the update page when an update error occurs" do
|
||||
join_org(user, organization, :admin)
|
||||
|
||||
visit "/settings/organization"
|
||||
fill_in "organization[name]", with: user.name
|
||||
click_button("Save")
|
||||
expect(page).to have_text("Organization details")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue