Commit 83f47163 authored by allison.browne's avatar allison.browne

Update specs from zoom notes service

parent 56403b97
...@@ -9,7 +9,7 @@ class ZoomNotesService ...@@ -9,7 +9,7 @@ class ZoomNotesService
end end
def execute def execute
return if @issue.zoom_meetings == @zoom_meetings return if @issue.zoom_meetings == @old_zoom_meetings
if zoom_link_added? if zoom_link_added?
zoom_link_added_notification zoom_link_added_notification
...@@ -21,7 +21,10 @@ class ZoomNotesService ...@@ -21,7 +21,10 @@ class ZoomNotesService
private private
def zoom_link_added? def zoom_link_added?
ZoomMeeting.canonical_meeting_url(@issue) meetings = @issue.zoom_meetings.select do |z|
z.issue_status == ZoomMeeting.issue_statuses[:added]
end
!meetings.empty?
end end
def zoom_link_added_notification def zoom_link_added_notification
......
...@@ -230,7 +230,9 @@ describe IssuablesHelper do ...@@ -230,7 +230,9 @@ describe IssuablesHelper do
end end
context 'with "added" zoom meeting' do context 'with "added" zoom meeting' do
before { create(:zoom_meeting, issue: issue) } before do
create(:zoom_meeting, issue: issue)
end
shared_examples 'sets zoomMeetingUrl to canonical meeting url' do shared_examples 'sets zoomMeetingUrl to canonical meeting url' do
specify do specify do
......
...@@ -226,13 +226,18 @@ describe Issues::UpdateService, :mailer do ...@@ -226,13 +226,18 @@ describe Issues::UpdateService, :mailer do
end end
end end
it 'creates zoom_link_added system note when a zoom link is added to the description' do context 'blah' do
update_issue(description: 'Changed description https://zoom.us/j/5873603787') before do
let(:zoom_meeting) { create(:zoom_meeting, issue: issue) }
end
it 'creates zoom_link_added system note when a zoom link is added to the description' do
update_issue(zoom_meetings: [zoom_meeting])
note = find_note('added a Zoom call') note = find_note('added a Zoom call')
expect(note).not_to be_nil expect(note).not_to be_nil
expect(note.note).to eq('added a Zoom call to this issue') expect(note.note).to eq('added a Zoom call to this issue')
end
end end
context 'when issue turns confidential' do context 'when issue turns confidential' do
......
...@@ -4,13 +4,15 @@ require 'spec_helper' ...@@ -4,13 +4,15 @@ require 'spec_helper'
describe ZoomNotesService do describe ZoomNotesService do
describe '#execute' do describe '#execute' do
let(:issue) { OpenStruct.new(description: description) } let(:issue) { OpenStruct.new(zoom_meetings: zoom_meetings) }
let(:project) { Object.new } let(:project) { Object.new }
let(:user) { Object.new } let(:user) { Object.new }
let(:description) { 'an issue description' } let(:added_zoom_meeting) { OpenStruct.new(issue_status: ZoomMeeting.issue_statuses[:added]) }
let(:old_description) { nil } let(:removed_zoom_meeting) { OpenStruct.new(issue_status: ZoomMeeting.issue_statuses[:removed]) }
let(:old_zoom_meetings) { [] }
let(:zoom_meetings) { [] }
subject { described_class.new(issue, project, user, old_description: old_description) } subject { described_class.new(issue, project, user, old_zoom_meetings: old_zoom_meetings) }
shared_examples 'no notifications' do shared_examples 'no notifications' do
it "doesn't create notifications" do it "doesn't create notifications" do
...@@ -21,30 +23,23 @@ describe ZoomNotesService do ...@@ -21,30 +23,23 @@ describe ZoomNotesService do
end end
end end
it_behaves_like 'no notifications' context 'when zoom_meetings == old_zoom_meetings' do
context 'when both are empty' do
context 'when the zoom link exists in both description and old_description' do it_behaves_like 'no notifications'
let(:description) { 'a changed issue description https://zoom.us/j/123' } end
let(:old_description) { 'an issue description https://zoom.us/j/123' }
it_behaves_like 'no notifications'
end
context "when the zoom link doesn't exist in both description and old_description" do context 'when both are removed' do
let(:description) { 'a changed issue description' } let(:old_zoom_meetings) { [removed_zoom_meeting] }
let(:old_description) { 'an issue description' } let(:zoom_meetings) { old_zoom_meetings }
it_behaves_like 'no notifications' it_behaves_like 'no notifications'
end
end end
context 'when description == old_description' do
let(:old_description) { 'an issue description' }
it_behaves_like 'no notifications'
end
context 'when the description contains a zoom link and old_description is nil' do context 'when old_zoom_meetings is empty and zoom_meetings contains an added zoom_meeting' do
let(:description) { 'a changed issue description https://zoom.us/j/123' } let(:old_zoom_meetings) { [] }
let(:zoom_meetings) { [added_zoom_meeting] }
it 'creates a zoom_link_added notification' do it 'creates a zoom_link_added notification' do
expect(SystemNoteService).to receive(:zoom_link_added).with(issue, project, user) expect(SystemNoteService).to receive(:zoom_link_added).with(issue, project, user)
...@@ -54,9 +49,9 @@ describe ZoomNotesService do ...@@ -54,9 +49,9 @@ describe ZoomNotesService do
end end
end end
context 'when the zoom link has been added to the description' do context 'when the zoom link has been added' do
let(:description) { 'a changed issue description https://zoom.us/j/123' } let(:old_zoom_meetings) { [removed_zoom_meeting] }
let(:old_description) { 'an issue description' } let(:zoom_meetings) { [removed_zoom_meeting, added_zoom_meeting] }
it 'creates a zoom_link_added notification' do it 'creates a zoom_link_added notification' do
expect(SystemNoteService).to receive(:zoom_link_added).with(issue, project, user) expect(SystemNoteService).to receive(:zoom_link_added).with(issue, project, user)
...@@ -66,9 +61,9 @@ describe ZoomNotesService do ...@@ -66,9 +61,9 @@ describe ZoomNotesService do
end end
end end
context 'when the zoom link has been removed from the description' do context 'when the zoom link has been removed from zoom_meetings' do
let(:description) { 'a changed issue description' } let(:old_zoom_meetings) { [added_zoom_meeting] }
let(:old_description) { 'an issue description https://zoom.us/j/123' } let(:zoom_meetings) { [removed_zoom_meeting] }
it 'creates a zoom_link_removed notification' do it 'creates a zoom_link_removed notification' do
expect(SystemNoteService).not_to receive(:zoom_link_added).with(issue, project, user) expect(SystemNoteService).not_to receive(:zoom_link_added).with(issue, project, user)
......
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