-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix problems with account updating and user groups / Add specs
- Loading branch information
1 parent
bb907af
commit 7a3b688
Showing
10 changed files
with
99 additions
and
9 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
35 changes: 35 additions & 0 deletions
35
app/controllers/concerns/decidim/privacy/admin/user_groups_controller_extensions.rb
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,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Privacy | ||
module Admin | ||
module UserGroupsControllerExtensions | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
def verify | ||
@user_group = collection.find(params[:id]) | ||
enforce_permission_to :verify, :user_group, user_group: @user_group | ||
|
||
Decidim::Admin::VerifyUserGroup.call(@user_group, current_user) do | ||
on(:ok) do | ||
flash[:notice] = I18n.t("user_group.verify.success", scope: "decidim.admin") | ||
redirect_back(fallback_location: decidim_admin.user_groups_path) | ||
end | ||
|
||
on(:invalid) do | ||
flash[:alert] = I18n.t("user_group.verify.invalid", scope: "decidim.admin") | ||
redirect_back(fallback_location: decidim_admin.user_groups_path) | ||
end | ||
|
||
on(:email_confirmation) do | ||
flash[:alert] = I18n.t("user_group.verify.confirmation_pending", scope: "decidim.admin") | ||
redirect_back(fallback_location: decidim_admin.user_groups_path) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
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
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 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,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
describe "Admin filters user_groups", type: :system do | ||
let(:organization) { create(:organization) } | ||
let!(:user) { create(:user, :admin, :confirmed, organization: organization) } | ||
let!(:pending_ug) { create(:user_group, organization: organization, users: [user]) } | ||
|
||
before do | ||
switch_to_host(organization.host) | ||
login_as user, scope: :user | ||
visit decidim_admin.user_groups_path | ||
end | ||
|
||
context "when user group is not confirmed" do | ||
it "gives a flash alert that the user group needs to be confirmed before verification" do | ||
within "td.table-list__actions" do | ||
click_link "Verify" | ||
end | ||
|
||
expect(page).to have_content("The group's email address has to be confirmed in order to verify the group.") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,4 +68,16 @@ | |
end | ||
end | ||
end | ||
|
||
context "when creating a user group" do | ||
it "gives a flash alert to check email for confirmation" do | ||
visit decidim.profile_path(public_member.nickname) | ||
click_link "Create group" | ||
fill_in(:group_name, with: "Example group") | ||
fill_in(:group_nickname, with: "eg") | ||
fill_in(:group_email, with: "[email protected]") | ||
click_button "Create group" | ||
expect(page).to have_content("Group successfully created! Please check the group's email address for a verification message to verify the group's email address") | ||
end | ||
end | ||
end |