Commit 48015ded authored by Semyon Pupkov's avatar Semyon Pupkov

Union examples in event spec fo speed up

parent d57d892e
...@@ -27,17 +27,17 @@ describe Event, models: true do ...@@ -27,17 +27,17 @@ describe Event, models: true do
end end
describe "Push event" do describe "Push event" do
before do let(:project) { create(:project) }
project = create(:project) let(:user) { project.owner }
@user = project.owner let(:event) { create_event(project, user) }
@event = create_event(project, @user)
it do
expect(event.push?).to be_truthy
expect(event.visible_to_user?).to be_truthy
expect(event.tag?).to be_falsey
expect(event.branch_name).to eq("master")
expect(event.author).to eq(user)
end end
it { expect(@event.push?).to be_truthy }
it { expect(@event.visible_to_user?).to be_truthy }
it { expect(@event.tag?).to be_falsey }
it { expect(@event.branch_name).to eq("master") }
it { expect(@event.author).to eq(@user) }
end end
describe '#note?' do describe '#note?' do
...@@ -59,8 +59,8 @@ describe Event, models: true do ...@@ -59,8 +59,8 @@ describe Event, models: true do
describe '#visible_to_user?' do describe '#visible_to_user?' do
let(:project) { create(:empty_project, :public) } let(:project) { create(:empty_project, :public) }
let(:non_member) { create(:user) } let(:non_member) { create(:user) }
let(:member) { create(:user) } let(:member) { create(:user) }
let(:guest) { create(:user) } let(:guest) { create(:user) }
let(:author) { create(:author) } let(:author) { create(:author) }
let(:assignee) { create(:user) } let(:assignee) { create(:user) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
...@@ -79,23 +79,27 @@ describe Event, models: true do ...@@ -79,23 +79,27 @@ describe Event, models: true do
context 'for non confidential issues' do context 'for non confidential issues' do
let(:target) { issue } let(:target) { issue }
it { expect(event.visible_to_user?(non_member)).to eq true } it do
it { expect(event.visible_to_user?(author)).to eq true } expect(event.visible_to_user?(non_member)).to eq true
it { expect(event.visible_to_user?(assignee)).to eq true } expect(event.visible_to_user?(author)).to eq true
it { expect(event.visible_to_user?(member)).to eq true } expect(event.visible_to_user?(assignee)).to eq true
it { expect(event.visible_to_user?(guest)).to eq true } expect(event.visible_to_user?(member)).to eq true
it { expect(event.visible_to_user?(admin)).to eq true } expect(event.visible_to_user?(guest)).to eq true
expect(event.visible_to_user?(admin)).to eq true
end
end end
context 'for confidential issues' do context 'for confidential issues' do
let(:target) { confidential_issue } let(:target) { confidential_issue }
it { expect(event.visible_to_user?(non_member)).to eq false } it do
it { expect(event.visible_to_user?(author)).to eq true } expect(event.visible_to_user?(non_member)).to eq false
it { expect(event.visible_to_user?(assignee)).to eq true } expect(event.visible_to_user?(author)).to eq true
it { expect(event.visible_to_user?(member)).to eq true } expect(event.visible_to_user?(assignee)).to eq true
it { expect(event.visible_to_user?(guest)).to eq false } expect(event.visible_to_user?(member)).to eq true
it { expect(event.visible_to_user?(admin)).to eq true } expect(event.visible_to_user?(guest)).to eq false
expect(event.visible_to_user?(admin)).to eq true
end
end end
end end
...@@ -103,23 +107,27 @@ describe Event, models: true do ...@@ -103,23 +107,27 @@ describe Event, models: true do
context 'on non confidential issues' do context 'on non confidential issues' do
let(:target) { note_on_issue } let(:target) { note_on_issue }
it { expect(event.visible_to_user?(non_member)).to eq true } it do
it { expect(event.visible_to_user?(author)).to eq true } expect(event.visible_to_user?(non_member)).to eq true
it { expect(event.visible_to_user?(assignee)).to eq true } expect(event.visible_to_user?(author)).to eq true
it { expect(event.visible_to_user?(member)).to eq true } expect(event.visible_to_user?(assignee)).to eq true
it { expect(event.visible_to_user?(guest)).to eq true } expect(event.visible_to_user?(member)).to eq true
it { expect(event.visible_to_user?(admin)).to eq true } expect(event.visible_to_user?(guest)).to eq true
expect(event.visible_to_user?(admin)).to eq true
end
end end
context 'on confidential issues' do context 'on confidential issues' do
let(:target) { note_on_confidential_issue } let(:target) { note_on_confidential_issue }
it { expect(event.visible_to_user?(non_member)).to eq false } it do
it { expect(event.visible_to_user?(author)).to eq true } expect(event.visible_to_user?(non_member)).to eq false
it { expect(event.visible_to_user?(assignee)).to eq true } expect(event.visible_to_user?(author)).to eq true
it { expect(event.visible_to_user?(member)).to eq true } expect(event.visible_to_user?(assignee)).to eq true
it { expect(event.visible_to_user?(guest)).to eq false } expect(event.visible_to_user?(member)).to eq true
it { expect(event.visible_to_user?(admin)).to eq true } expect(event.visible_to_user?(guest)).to eq false
expect(event.visible_to_user?(admin)).to eq true
end
end end
end end
...@@ -129,22 +137,26 @@ describe Event, models: true do ...@@ -129,22 +137,26 @@ describe Event, models: true do
let(:note_on_merge_request) { create(:legacy_diff_note_on_merge_request, noteable: merge_request, project: project) } let(:note_on_merge_request) { create(:legacy_diff_note_on_merge_request, noteable: merge_request, project: project) }
let(:target) { note_on_merge_request } let(:target) { note_on_merge_request }
it { expect(event.visible_to_user?(non_member)).to eq true } it do
it { expect(event.visible_to_user?(author)).to eq true } expect(event.visible_to_user?(non_member)).to eq true
it { expect(event.visible_to_user?(assignee)).to eq true } expect(event.visible_to_user?(author)).to eq true
it { expect(event.visible_to_user?(member)).to eq true } expect(event.visible_to_user?(assignee)).to eq true
it { expect(event.visible_to_user?(guest)).to eq true } expect(event.visible_to_user?(member)).to eq true
it { expect(event.visible_to_user?(admin)).to eq true } expect(event.visible_to_user?(guest)).to eq true
expect(event.visible_to_user?(admin)).to eq true
end
context 'private project' do context 'private project' do
let(:project) { create(:project, :private) } let(:project) { create(:project, :private) }
it { expect(event.visible_to_user?(non_member)).to eq false } it do
it { expect(event.visible_to_user?(author)).to eq true } expect(event.visible_to_user?(non_member)).to eq false
it { expect(event.visible_to_user?(assignee)).to eq true } expect(event.visible_to_user?(author)).to eq true
it { expect(event.visible_to_user?(member)).to eq true } expect(event.visible_to_user?(assignee)).to eq true
it { expect(event.visible_to_user?(guest)).to eq false } expect(event.visible_to_user?(member)).to eq true
it { expect(event.visible_to_user?(admin)).to eq true } expect(event.visible_to_user?(guest)).to eq false
expect(event.visible_to_user?(admin)).to eq true
end
end end
end end
end end
...@@ -214,6 +226,6 @@ describe Event, models: true do ...@@ -214,6 +226,6 @@ describe Event, models: true do
action: Event::PUSHED, action: Event::PUSHED,
data: data, data: data,
author_id: user.id author_id: user.id
}.merge(attrs)) }.merge!(attrs))
end 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