Commit 4f565864 authored by Sean Arnold's avatar Sean Arnold

Add specs for multiple images

parent 9dfc8b3a
...@@ -6,11 +6,8 @@ RSpec.describe AlertManagement::CreateAlertIssueService do ...@@ -6,11 +6,8 @@ RSpec.describe AlertManagement::CreateAlertIssueService do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) } let_it_be(:project) { create(:project, group: group) }
let_it_be(:alert) { create(:alert_management_alert, project: project) } let_it_be(:alert) { create(:alert_management_alert, project: project) }
let(:created_issue) { Issue.last! }
describe '#execute' do describe '#execute' do
subject(:execute) { described_class.new(alert, user).execute } subject(:execute) { described_class.new(alert, user).execute }
...@@ -21,18 +18,25 @@ RSpec.describe AlertManagement::CreateAlertIssueService do ...@@ -21,18 +18,25 @@ RSpec.describe AlertManagement::CreateAlertIssueService do
it 'copies any metric images' do it 'copies any metric images' do
image = create(:alert_metric_image, alert: alert) image = create(:alert_metric_image, alert: alert)
image_2 = create(:alert_metric_image, alert: alert)
incident = execute.payload[:issue]
execute expect(incident.metric_images.count).to eq(2)
incident = Issue.incident.last first_metric_image, second_metric_image = incident.metric_images.order(:created_at)
expect_image_matches(first_metric_image, image)
expect_image_matches(second_metric_image, image_2)
end
expect(incident.metric_images.count).to eq(1) private
metric_image = incident.metric_images.first def expect_image_matches(image, image_expectation)
expect(metric_image.url).to eq(image.url) expect(image.url).to eq(image_expectation.url)
expect(metric_image.url_text).to eq(image.url_text) expect(image.url_text).to eq(image_expectation.url_text)
expect(metric_image.filename).to eq(image.filename) expect(image.filename).to eq(image_expectation.filename)
expect(metric_image.file).not_to eq(image.file) expect(image.file).not_to eq(image_expectation.file)
end end
end 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