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

Update specs from zoom notes service

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