Skip to content

Commit

Permalink
Specs
Browse files Browse the repository at this point in the history
  • Loading branch information
zwolf committed Nov 29, 2023
1 parent 2dccd27 commit 0599b0d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
admin false
banned false
created_at Time.now - 1.year
confirmed_at Time.now - 364.days

factory :moderator do
transient do
Expand Down
6 changes: 6 additions & 0 deletions spec/policies/comment_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
it_behaves_like 'a policy forbidding', :update, :destroy
end

context 'with an unconfirmed user' do
let(:user){ create :user, confirmed_at: nil }
it_behaves_like 'a policy permitting', :index, :show, :upvote, :remove_upvote
it_behaves_like 'a policy forbidding', :update, :destroy, :move
end

context 'with a new account' do
let(:user){ create :user, created_at: Time.now }
ENV['POSTING_AGE_REQUIREMENT'] = '24'
Expand Down
5 changes: 5 additions & 0 deletions spec/policies/conversation_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
it_behaves_like 'a policy forbidding', :show, :update, :destroy
end

context 'with an unconfirmed user' do
let(:user){ create :user, confirmed_at: nil }
it_behaves_like 'a policy forbidding', :index, :show, :create, :destroy, :update
end

context 'with a participant' do
let(:user){ record.users.first }
it_behaves_like 'a policy permitting', :index, :show, :create, :destroy
Expand Down
7 changes: 7 additions & 0 deletions spec/policies/discussion_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
it_behaves_like 'a policy forbidding', :create, :update, :destroy
end

context 'with an unconfirmed user' do
let(:user){ create :user, confirmed_at: nil }
let(:board){ create :board, section: 'zooniverse', permissions: { read: 'all', write: 'all' } }
it_behaves_like 'a policy permitting', :index, :show
it_behaves_like 'a policy forbidding', :create, :update, :destroy
end

context 'with the owner' do
let(:user){ record.user }
it_behaves_like 'a policy permitting', :index, :show, :create, :update
Expand Down
5 changes: 5 additions & 0 deletions spec/policies/message_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
it_behaves_like 'a policy forbidding', :show, :create, :update, :destroy
end

context 'with an unconfirmed user' do
let(:user){ create :user, confirmed_at: nil }
it_behaves_like 'a policy forbidding', :index, :show, :create, :update, :destroy
end

context 'with a participant' do
let(:user){ record.user }
it_behaves_like 'a policy permitting', :index, :show, :create
Expand Down

0 comments on commit 0599b0d

Please sign in to comment.