Commit 6824ba14 authored by sfang97's avatar sfang97

DRY user_spec terms, add term_spec

parent af1be746
......@@ -35,6 +35,7 @@ RSpec.describe 'Users > Terms' do
it 'auto accepts the terms' do
visit terms_path
expect(page).not_to have_content('Accept terms')
expect(project_bot.terms_accepted?).to be(true)
end
......
......@@ -17,6 +17,7 @@ RSpec.describe ApplicationSetting::Term do
describe '#accepted_by_user?' do
let(:user) { create(:user) }
let(:project_bot) { create(:user, :project_bot) }
let(:term) { create(:term) }
it 'is true when the user accepted the terms' do
......@@ -25,6 +26,10 @@ RSpec.describe ApplicationSetting::Term do
expect(term.accepted_by_user?(user)).to be(true)
end
it 'is true when user is a bot' do
expect(term.accepted_by_user?(project_bot)).to be(true)
end
it 'is false when the user declined the terms' do
decline_terms(term, user)
......
......@@ -4330,6 +4330,7 @@ RSpec.describe User do
describe '#required_terms_not_accepted?' do
let(:user) { build(:user) }
let(:project_bot) { create(:user, :project_bot) }
subject { user.required_terms_not_accepted? }
......@@ -4337,21 +4338,24 @@ RSpec.describe User do
it { is_expected.to be_falsy }
end
context "when terms are enforced and accepted by the user" do
context "when terms are enforced" do
before do
enforce_terms
accept_terms(user)
end
it { is_expected.to be_falsy }
end
it "is accepted by the user" do
accept_terms(user)
context "when terms are enforced but the user has not accepted" do
before do
enforce_terms
it { is_expected.to be_falsy }
end
it "is not accepted by the user" do
it { is_expected.to be_truthy }
end
it { is_expected.to be_truthy }
it "auto accepts the term for project bots" do
expect(project_bot.required_terms_not_accepted?).to be_falsy
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment