summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-03-24 14:20:47 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-03-24 14:22:01 -0300
commit239560331ab5ef635a8739f5b2b85d0bcd531256 (patch)
tree45c205cb6cc65f5c531faa386064b11217c4b909 /spec
parent6b95be1ddd144e24a61564349fa550b3a98336c7 (diff)
downloadgitlab-ce-239560331ab5ef635a8739f5b2b85d0bcd531256.tar.gz
Comments on confidential issues doesn't show in activity feed to non-members
Diffstat (limited to 'spec')
-rw-r--r--spec/models/event_spec.rb54
1 files changed, 40 insertions, 14 deletions
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
index 5fe44246738..697a34022ce 100644
--- a/spec/models/event_spec.rb
+++ b/spec/models/event_spec.rb
@@ -66,21 +66,25 @@ describe Event, models: true do
end
describe '#proper?' do
- context 'issue event' do
- let(:project) { create(:empty_project, :public) }
- let(:non_member) { create(:user) }
- let(:member) { create(:user) }
- let(:author) { create(:author) }
- let(:assignee) { create(:user) }
- let(:admin) { create(:admin) }
- let(:event) { Event.new(project: project, action: Event::CREATED, target: issue, author_id: author.id) }
-
- before do
- project.team << [member, :developer]
- end
+ let(:project) { create(:empty_project, :public) }
+ let(:non_member) { create(:user) }
+ let(:member) { create(:user) }
+ let(:author) { create(:author) }
+ let(:assignee) { create(:user) }
+ let(:admin) { create(:admin) }
+ let(:issue) { create(:issue, project: project, author: author, assignee: assignee) }
+ let(:confidential_issue) { create(:issue, :confidential, project: project, author: author, assignee: assignee) }
+ let(:note_on_issue) { create(:note_on_issue, noteable: issue, project: project) }
+ let(:note_on_confidential_issue) { create(:note_on_issue, noteable: confidential_issue, project: project) }
+ let(:event) { Event.new(project: project, target: target, author_id: author.id) }
+
+ before do
+ project.team << [member, :developer]
+ end
+ context 'issue event' do
context 'for non confidential issues' do
- let(:issue) { create(:issue, project: project, author: author, assignee: assignee) }
+ let(:target) { issue }
it { expect(event.proper?(non_member)).to eq true }
it { expect(event.proper?(author)).to eq true }
@@ -90,7 +94,29 @@ describe Event, models: true do
end
context 'for confidential issues' do
- let(:issue) { create(:issue, :confidential, project: project, author: author, assignee: assignee) }
+ let(:target) { confidential_issue }
+
+ it { expect(event.proper?(non_member)).to eq false }
+ it { expect(event.proper?(author)).to eq true }
+ it { expect(event.proper?(assignee)).to eq true }
+ it { expect(event.proper?(member)).to eq true }
+ it { expect(event.proper?(admin)).to eq true }
+ end
+ end
+
+ context 'note event' do
+ context 'on non confidential issues' do
+ let(:target) { note_on_issue }
+
+ it { expect(event.proper?(non_member)).to eq true }
+ it { expect(event.proper?(author)).to eq true }
+ it { expect(event.proper?(assignee)).to eq true }
+ it { expect(event.proper?(member)).to eq true }
+ it { expect(event.proper?(admin)).to eq true }
+ end
+
+ context 'on confidential issues' do
+ let(:target) { note_on_confidential_issue }
it { expect(event.proper?(non_member)).to eq false }
it { expect(event.proper?(author)).to eq true }