diff options
author | Reuben Pereira <rpereira@gitlab.com> | 2019-01-07 17:55:21 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-01-07 17:55:21 +0000 |
commit | f40b5860d76a8ea5d964260834a6e83516b0f1fd (patch) | |
tree | 2a8e92896130697178f5c989e49fa686f66ce073 /spec/models | |
parent | 549ee8ada3b59278871a89720632584bc5cc11df (diff) | |
download | gitlab-ce-f40b5860d76a8ea5d964260834a6e83516b0f1fd.tar.gz |
Add table and model for error tracking settings
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/error_tracking/project_error_tracking_setting_spec.rb | 36 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 1 |
2 files changed, 37 insertions, 0 deletions
diff --git a/spec/models/error_tracking/project_error_tracking_setting_spec.rb b/spec/models/error_tracking/project_error_tracking_setting_spec.rb new file mode 100644 index 00000000000..83f29718eda --- /dev/null +++ b/spec/models/error_tracking/project_error_tracking_setting_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe ErrorTracking::ProjectErrorTrackingSetting do + set(:project) { create(:project) } + + describe 'Associations' do + it { is_expected.to belong_to(:project) } + end + + describe 'Validations' do + subject { create(:project_error_tracking_setting, project: project) } + + context 'when api_url is over 255 chars' do + before do + subject.api_url = 'https://' + 'a' * 250 + end + + it 'fails validation' do + expect(subject).not_to be_valid + expect(subject.errors.messages[:api_url]).to include('is too long (maximum is 255 characters)') + end + end + + context 'With unsafe url' do + let(:project_error_tracking_setting) { create(:project_error_tracking_setting, project: project) } + + it 'fails validation' do + project_error_tracking_setting.api_url = "https://replaceme.com/'><script>alert(document.cookie)</script>" + + expect(project_error_tracking_setting).not_to be_valid + end + end + end +end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 65b59c7b21b..5e7345ca180 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -62,6 +62,7 @@ describe Project do it { is_expected.to have_one(:last_event).class_name('Event') } it { is_expected.to have_one(:forked_from_project).through(:fork_network_member) } it { is_expected.to have_one(:auto_devops).class_name('ProjectAutoDevops') } + it { is_expected.to have_one(:error_tracking_setting).class_name('ErrorTracking::ProjectErrorTrackingSetting') } it { is_expected.to have_many(:commit_statuses) } it { is_expected.to have_many(:ci_pipelines) } it { is_expected.to have_many(:builds) } |