-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
b8fbb92
commit c469ac9
Showing
3 changed files
with
73 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe GlobalPolicy do | ||
subject { described_class.new(current_user, nil) } | ||
|
||
context 'when user is present' do | ||
let(:current_user) { create(:user) } | ||
|
||
it { is_expected.to be_allowed(:create_team) } | ||
end | ||
|
||
context 'when user is nil' do | ||
let(:current_user) { nil } | ||
|
||
it { is_expected.not_to be_allowed(:create_team) } | ||
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe TeamPolicy do | ||
subject { described_class.new(current_user, team) } | ||
|
||
let(:current_user) { nil } | ||
|
||
context 'when user is member of the team' do | ||
let(:current_user) { create(:user) } | ||
let(:team) { create(:team).tap { |team| create(:team_member, team: team, user: current_user) } } | ||
|
||
it { is_expected.to be_allowed(:read_team) } | ||
it { is_expected.to be_allowed(:read_team_member) } | ||
end | ||
|
||
context 'when user is not member of the team' do | ||
let(:current_user) { create(:user) } | ||
let(:team) { create(:team) } | ||
|
||
it { is_expected.not_to be_allowed(:read_team) } | ||
it { is_expected.not_to be_allowed(:read_team_member) } | ||
end | ||
|
||
context 'when user is nil' do | ||
let(:current_user) { nil } | ||
let(:team) { create(:team) } | ||
|
||
it { is_expected.not_to be_allowed(:read_team) } | ||
it { is_expected.not_to be_allowed(:read_team_member) } | ||
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe UserPolicy do | ||
subject { described_class.new(current_user, user) } | ||
|
||
let(:user) { create(:user) } | ||
|
||
context 'when user is present' do | ||
let(:current_user) { create(:user) } | ||
|
||
it { is_expected.to be_allowed(:read_user) } | ||
end | ||
|
||
context 'when user is nil' do | ||
let(:current_user) { nil } | ||
|
||
it { is_expected.not_to be_allowed(:read_user) } | ||
end | ||
end |