Commit b9626ae8 authored by allison.browne's avatar allison.browne

Clean up zoom specs

parent 97330c56
......@@ -14,10 +14,10 @@ class ZoomMeeting < ApplicationRecord
scope :added_to_issue, -> { where(issue_status: :added) }
scope :removed_from_issue, -> { where(issue_status: :removed) }
scope :canonical_meetings, -> (issue) { where(issue: issue)&.added_to_issue }
scope :canonical, -> (issue) { where(issue: issue)&.added_to_issue }
def self.canonical_meeting(issue)
canonical_meetings(issue)&.first
canonical(issue)&.first
end
def self.canonical_meeting_url(issue)
......
......@@ -6,7 +6,7 @@ module Issues
super(issue.project, user)
@issue = issue
@added_meeting = fetch_added_meeting
@added_meeting = ZoomMeeting.canonical_meeting(@issue)
end
def add_link(link)
......@@ -41,10 +41,6 @@ module Issues
attr_reader :issue
def fetch_added_meeting
ZoomMeeting.canonical_meeting(@issue)
end
def track_meeting_added_event
::Gitlab::Tracking.event('IncidentManagement::ZoomIntegration', 'add_zoom_meeting', label: 'Issue ID', value: issue.id)
end
......
......@@ -252,7 +252,6 @@ describe IssuablesHelper do
it_behaves_like 'sets zoomMeetingUrl to canonical meeting url'
end
end
end
end
......
......@@ -226,7 +226,7 @@ describe Issues::UpdateService, :mailer do
end
end
context 'when zoom meetings is changed' do
context 'when zoom_meetings is changed' do
it 'creates zoom_link_added system note when a zoom link is added' do
update_issue(zoom_meetings: [create(:zoom_meeting, issue: issue)])
note = find_note('added a Zoom call')
......
......@@ -35,7 +35,7 @@ describe Issues::ZoomLinkService do
describe '#add_link' do
shared_examples 'can add meeting' do
it 'appends the link zoom_meetings' do
it 'appends the new meeting to zoom_meetings' do
expect(result).to be_success
expect(result.payload[:zoom_meetings].map(&:url))
.to include(zoom_link)
......@@ -60,7 +60,7 @@ describe Issues::ZoomLinkService do
context 'without existing Zoom meeting' do
include_examples 'can add meeting'
context 'with invalid Zoom meeting' do
context 'with invalid Zoom url' do
let(:zoom_link) { 'https://not-zoom.link' }
include_examples 'cannot add meeting'
......@@ -81,8 +81,7 @@ describe Issues::ZoomLinkService do
describe '#can_add_link?' do
subject { service.can_add_link? }
context 'without Zoom link' do
context 'without "added" zoom meeting' do
it { is_expected.to eq(true) }
context 'with insufficient permissions' do
......@@ -110,10 +109,10 @@ describe Issues::ZoomLinkService do
shared_examples 'can remove meeting' do
it 'can remove the meeting' do
expect(result).to be_success
expect(result.payload[:zoom_meetings].filter { |z| z.issue_status == 1 })
expect(result.payload[:zoom_meetings].filter { |z| z.issue_status == "added" })
.to be_empty
end
it 'tracks the remove event' do
expect(Gitlab::Tracking).to receive(:event)
.with('IncidentManagement::ZoomIntegration', 'remove_zoom_meeting', label: 'Issue ID', value: issue.id)
......
......@@ -14,24 +14,22 @@ shared_examples 'zoom quick actions' do
expect(page).not_to have_content('Zoom meeting added')
expect(page).not_to have_content('Failed to add a Zoom meeting')
expect(issue.reload.zoom_meetings[0].url).not_to eq(zoom_link)
expect(ZoomMeeting.canonical_meeting_url(issue.reload)).not_to eq(zoom_link)
end
end
shared_examples 'success' do
it 'adds a Zoom link' do
add_note("/zoom #{zoom_link}")
wait_for_requests
expect(page).to have_content('Zoom meeting added')
expect(issue.reload.zoom_meetings[0].url).to eq(zoom_link)
expect(ZoomMeeting.canonical_meeting_url(issue.reload)).to eq(zoom_link)
end
end
context 'without zoom_meetings' do
include_examples 'success'
it 'cannot add invalid zoom link' do
......@@ -70,7 +68,7 @@ shared_examples 'zoom quick actions' do
expect(page).not_to have_content('Zoom meeting removed')
expect(page).not_to have_content('Failed to remove a Zoom meeting')
expect(issue.reload.zoom_meetings.filter { |z| z.issue_status == ZoomMeeting.issue_statuses[:added] }).to be_empty
expect(ZoomMeeting.canonical_meeting_url(issue.reload)).to be_nil
end
end
......@@ -83,7 +81,7 @@ shared_examples 'zoom quick actions' do
wait_for_requests
expect(page).to have_content('Zoom meeting removed')
expect(issue.reload.zoom_meetings.filter { |z| z.issue_status == ZoomMeeting.issue_statuses[:added] }).to be_empty
expect(ZoomMeeting.canonical_meeting_url(issue.reload)).to be_nil
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