diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-08-23 09:27:24 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-08-23 09:27:24 +0000 |
commit | 8e27c3db443de317f5bbea67ba4ed98641bbd7eb (patch) | |
tree | 28709e10eb40f4c4a3ef424c979d8d1b966cb034 /spec | |
parent | 101d52b360a6a43f1633c5dd60b78e37bc8c4339 (diff) | |
parent | b4aaced71a65faffd49ffa2c705fb574ed532701 (diff) | |
download | gitlab-ce-8e27c3db443de317f5bbea67ba4ed98641bbd7eb.tar.gz |
Merge branch 'fix-push-events-branch-removals' into 'master'
Fix displaying events of removed events and events without commit messages
Closes #36685 and #36722
See merge request !13721
Diffstat (limited to 'spec')
-rw-r--r-- | spec/helpers/events_helper_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/event_spec.rb | 44 |
2 files changed, 48 insertions, 0 deletions
diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index 4b72dbb7964..d5536fcb22b 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -106,5 +106,9 @@ describe EventsHelper do it "handles empty strings" do expect(helper.event_commit_title("")).to eq("") end + + it 'handles nil values' do + expect(helper.event_commit_title(nil)).to eq('') + end end end diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index ff3224dd298..f55c161c821 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -304,6 +304,50 @@ describe Event do end end + describe '#body?' do + let(:push_event) do + event = build(:push_event) + + allow(event).to receive(:push?).and_return(true) + + event + end + + it 'returns true for a push event with commits' do + allow(push_event).to receive(:push_with_commits?).and_return(true) + + expect(push_event).to be_body + end + + it 'returns false for a push event without a valid commit range' do + allow(push_event).to receive(:push_with_commits?).and_return(false) + + expect(push_event).not_to be_body + end + + it 'returns true for a Note event' do + event = build(:event) + + allow(event).to receive(:note?).and_return(true) + + expect(event).to be_body + end + + it 'returns true if the target responds to #title' do + event = build(:event) + + allow(event).to receive(:target).and_return(double(:target, title: 'foo')) + + expect(event).to be_body + end + + it 'returns false for a regular event without a target' do + event = build(:event) + + expect(event).not_to be_body + end + end + def create_push_event(project, user) event = create(:push_event, project: project, author: user) |