|
152 | 152 | expect(new_user.has_role?(Role::ORG_ADMIN, organization)).to be_falsey |
153 | 153 | end |
154 | 154 |
|
| 155 | + context "flash notice behavior" do |
| 156 | + context "when creating a new user" do |
| 157 | + it "shows 'Created a new user!' message" do |
| 158 | + post admin_users_path, params: { |
| 159 | + user: { name: "New User", email: "new@example.com" }, |
| 160 | + resource_type: Role::ORG_USER, |
| 161 | + resource_id: organization.id |
| 162 | + } |
| 163 | + expect(response).to redirect_to(admin_users_path) |
| 164 | + expect(flash[:notice]).to eq("Created a new user!") |
| 165 | + end |
| 166 | + end |
| 167 | + |
| 168 | + context "when adding a role to an existing user" do |
| 169 | + let!(:existing_user) { create(:user, email: "existing@example.com", organization: organization) } |
| 170 | + |
| 171 | + it "shows 'Added new role to existing user' message" do |
| 172 | + post admin_users_path, params: { |
| 173 | + user: { name: existing_user.name, email: existing_user.email }, |
| 174 | + resource_type: Role::PARTNER, |
| 175 | + resource_id: partner.id |
| 176 | + } |
| 177 | + expect(response).to redirect_to(admin_users_path) |
| 178 | + expect(flash[:notice]).to eq("Added new role to existing user") |
| 179 | + end |
| 180 | + end |
| 181 | + end |
| 182 | + |
155 | 183 | it "creates an org admin" do |
156 | 184 | post admin_users_path, params: { |
157 | 185 | user: { name: "New Org Admin", email: organization.email }, |
|
0 commit comments