Commit 24b5589c authored by Sean Arnold's avatar Sean Arnold

Fix some tests

parent b1044aeb
......@@ -27,6 +27,7 @@ module AlertManagement
has_many :notes, as: :noteable, inverse_of: :noteable, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
has_many :ordered_notes, -> { fresh }, as: :noteable, class_name: 'Note'
has_many :user_mentions, class_name: 'AlertManagement::AlertUserMention', foreign_key: :alert_management_alert_id
has_many :metric_images, class_name: '::AlertManagement::MetricImage'
has_internal_id :iid, scope: :project
......
......@@ -9,7 +9,6 @@ module EE
include AfterCommitQueue
has_many :pending_escalations, class_name: 'IncidentManagement::PendingEscalations::Alert', foreign_key: :alert_id, inverse_of: :alert
has_many :metric_images, class_name: '::AlertManagement::MetricImage'
after_create do |alert|
run_after_commit { alert.trigger_auto_rollback }
......
......@@ -12,6 +12,7 @@ module Gitlab
file
import_export
issuable_metric_image
metric_image
namespace_file
personal_file
].freeze
......
......@@ -19,6 +19,8 @@ RSpec.describe AlertManagement::MetricImage do
describe '.available_for?' do
subject { described_class.available_for?(issue.project) }
let_it_be_with_refind(:issue) { create(:issue) }
it { is_expected.to eq(true) }
end
end
......@@ -44,43 +44,35 @@ RSpec.describe AlertManagement::MetricImages::UploadService do
project.add_developer(current_user)
end
it_behaves_like 'no metric saved, an error given', 'You are not authorized to upload metric images'
it_behaves_like 'uploads the metric'
context 'with license' do
before do
stub_licensed_features(alert_metric_upload: true)
context 'no url given' do
let(:params) do
{
file: fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg')
}
end
it_behaves_like 'uploads the metric'
end
context 'no url given' do
let(:params) do
{
file: fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg')
}
end
it_behaves_like 'uploads the metric'
context 'record invalid' do
let(:params) do
{
file: fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain'),
url: 'https://www.gitlab.com'
}
end
context 'record invalid' do
let(:params) do
{
file: fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain'),
url: 'https://www.gitlab.com'
}
end
it_behaves_like 'no metric saved, an error given', /File does not have a supported extension. Only png, jpg, jpeg, gif, bmp, tiff, ico, and webp are supported/ # rubocop: disable Layout/LineLength
end
it_behaves_like 'no metric saved, an error given', /File does not have a supported extension. Only png, jpg, jpeg, gif, bmp, tiff, ico, and webp are supported/
context 'user is guest' do
before_all do
project.add_guest(current_user)
end
context 'user is guest' do
before_all do
project.add_guest(current_user)
end
it_behaves_like 'no metric saved, an error given', 'You are not authorized to upload metric images'
end
it_behaves_like 'no metric saved, an error given', 'You are not authorized to upload metric images'
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