diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 8d32fef0..1c1e47f0 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -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 diff --git a/spec/policies/comment_policy_spec.rb b/spec/policies/comment_policy_spec.rb index 54970db7..cf3aeec2 100644 --- a/spec/policies/comment_policy_spec.rb +++ b/spec/policies/comment_policy_spec.rb @@ -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' diff --git a/spec/policies/conversation_policy_spec.rb b/spec/policies/conversation_policy_spec.rb index abad31c9..77daa025 100644 --- a/spec/policies/conversation_policy_spec.rb +++ b/spec/policies/conversation_policy_spec.rb @@ -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 diff --git a/spec/policies/discussion_policy_spec.rb b/spec/policies/discussion_policy_spec.rb index 9c200d4e..8cf0f93a 100644 --- a/spec/policies/discussion_policy_spec.rb +++ b/spec/policies/discussion_policy_spec.rb @@ -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 diff --git a/spec/policies/message_policy_spec.rb b/spec/policies/message_policy_spec.rb index ed7bb597..0462e881 100644 --- a/spec/policies/message_policy_spec.rb +++ b/spec/policies/message_policy_spec.rb @@ -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