-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1539 from betagouv/stats_policy_tests
Add stats policy and authorize team link
- Loading branch information
Showing
4 changed files
with
22 additions
and
3 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
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
module Stats | ||
class BaseController < PagesController | ||
include Pundit | ||
|
||
private | ||
|
||
def stats_params | ||
|
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,20 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Stats::AllPolicy, type: :policy do | ||
let(:no_user) { nil } | ||
let(:user) { create :user } | ||
let(:admin) { create :user, is_admin: true } | ||
|
||
subject { described_class } | ||
|
||
permissions :team? do | ||
context "grants access to admin" do | ||
it { is_expected.to permit(admin, Stats::All) } | ||
end | ||
|
||
context "denies access to no admin user" do | ||
it { is_expected.not_to permit(user, Stats::All) } | ||
it { is_expected.not_to permit(no_user, Stats::All) } | ||
end | ||
end | ||
end |