forked from decidim-ice/decidim-module-decidim_awesome
-
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.
- Loading branch information
Showing
8 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
app/controllers/decidim/decidim_awesome/admin/admin_actions_controller.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,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module DecidimAwesome | ||
module Admin | ||
class AdminActionsController < DecidimAwesome::Admin::ApplicationController | ||
include NeedsAwesomeConfig | ||
|
||
layout "decidim/admin/users" | ||
before_action do | ||
enforce_permission_to :edit_config, :allow_admin_accountability | ||
end | ||
|
||
def index; end | ||
|
||
def export_xls | ||
# TODO: export to xls | ||
end | ||
end | ||
end | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
app/views/decidim/decidim_awesome/admin/admin_actions/index.html.erb
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,8 @@ | ||
<div class="card"> | ||
<div class="card-divider"> | ||
<h2 class="card-title"><%= t("menu.admin_accountability", scope: "decidim.admin", default: "Admin accountability") %></h2> | ||
</div> | ||
<div class="card-section"> | ||
<p>List of admin actions</p> | ||
</div> | ||
</div> |
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,40 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
module Decidim::DecidimAwesome | ||
module Admin | ||
describe AdminActionsController, type: :controller do | ||
routes { Decidim::DecidimAwesome::AdminEngine.routes } | ||
|
||
let(:user) { create(:user, :confirmed, :admin, organization: organization) } | ||
let(:organization) { create(:organization) } | ||
let(:allow_admin_accountability) { true } | ||
|
||
before do | ||
request.env["decidim.current_organization"] = user.organization | ||
sign_in user, scope: :user | ||
|
||
allow(Decidim::DecidimAwesome.config).to receive(:allow_admin_accountability).and_return(allow_admin_accountability) | ||
end | ||
|
||
describe "GET #index" do | ||
context "when admin accountability is enabled" do | ||
it "returns http success" do | ||
get :index, params: {} | ||
expect(response).to have_http_status(:success) | ||
end | ||
end | ||
|
||
context "when admin accountability is disabled" do | ||
let!(:allow_admin_accountability) { :disabled } | ||
|
||
it "returns http success" do | ||
get :index, params: {} | ||
expect(response).to have_http_status(:found) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe "Admin accountability", type: :system do | ||
let(:organization) { create :organization } | ||
let!(:user) { create :user, :admin, :confirmed, organization: organization } | ||
let(:status) { true } | ||
|
||
before do | ||
allow(Decidim::DecidimAwesome.config).to receive(:allow_admin_accountability).and_return(status) | ||
switch_to_host(organization.host) | ||
login_as user, scope: :user | ||
|
||
visit decidim_admin.root_path | ||
end | ||
|
||
context "when admin accountability is enabled" do | ||
it "shows the admin accountability link" do | ||
click_link "Participants" | ||
|
||
expect(page).to have_content("Admin accountability") | ||
end | ||
end | ||
|
||
context "when admin accountability is disabled" do | ||
let(:status) { :disabled } | ||
|
||
it "does not show the admin accountability link" do | ||
click_link "Participants" | ||
|
||
expect(page).not_to have_content("Admin accountability") | ||
end | ||
end | ||
end |