summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarka Košanová <jarka@gitlab.com>2019-06-18 09:25:38 +0200
committerJarka Košanová <jarka@gitlab.com>2019-09-10 14:19:18 +0200
commit34bb2453f3e692429ce30cd4b832670d497055de (patch)
tree7d1252fa4b2bf11a5084becb9542d869a664f231
parent5975f55c555330423aab49e7e0d2da2049a39200 (diff)
downloadgitlab-ce-34bb2453f3e692429ce30cd4b832670d497055de.tar.gz
Move urls valiadtion specs
-rw-r--r--spec/models/project_services/jira_service_spec.rb72
-rw-r--r--spec/models/project_services/jira_tracker_data_spec.rb46
2 files changed, 45 insertions, 73 deletions
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb
index 02060699e9a..ae109aadcc0 100644
--- a/spec/models/project_services/jira_service_spec.rb
+++ b/spec/models/project_services/jira_service_spec.rb
@@ -32,78 +32,6 @@ describe JiraService do
describe 'Associations' do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
- it { is_expected.to allow_value(nil).for(:jira_issue_transition_id) }
- it { is_expected.to allow_value('1,2,3').for(:jira_issue_transition_id) }
- it { is_expected.to allow_value('1;2;3').for(:jira_issue_transition_id) }
- it { is_expected.not_to allow_value('a,b,cd').for(:jira_issue_transition_id) }
- end
-
- describe 'Validations' do
- context 'when service is active' do
- before do
- subject.active = true
- end
-
- it { is_expected.to validate_presence_of(:url) }
- it_behaves_like 'issue tracker service URL attribute', :url
- end
-
- context 'when service is inactive' do
- before do
- subject.active = false
- end
-
- it { is_expected.not_to validate_presence_of(:url) }
- it { is_expected.not_to validate_presence_of(:username) }
- it { is_expected.not_to validate_presence_of(:password) }
- end
-
- context 'validating urls' do
- let(:service) do
- described_class.new(
- project: create(:project),
- active: true,
- username: 'username',
- password: 'test',
- jira_issue_transition_id: 24,
- url: 'http://jira.test.com'
- )
- end
-
- it 'is valid when all fields have required values' do
- expect(service).to be_valid
- end
-
- it 'is not valid when url is not a valid url' do
- service.url = 'not valid'
-
- expect(service).not_to be_valid
- end
-
- it 'is not valid when api url is not a valid url' do
- service.api_url = 'not valid'
-
- expect(service).not_to be_valid
- end
-
- it 'is not valid when username is missing' do
- service.username = nil
-
- expect(service).not_to be_valid
- end
-
- it 'is not valid when password is missing' do
- service.password = nil
-
- expect(service).not_to be_valid
- end
-
- it 'is valid when api url is a valid url' do
- service.api_url = 'http://jira.test.com/api'
-
- expect(service).to be_valid
- end
- end
end
describe '.reference_pattern' do
diff --git a/spec/models/project_services/jira_tracker_data_spec.rb b/spec/models/project_services/jira_tracker_data_spec.rb
index 1b6ece8531b..4c411d8ac3d 100644
--- a/spec/models/project_services/jira_tracker_data_spec.rb
+++ b/spec/models/project_services/jira_tracker_data_spec.rb
@@ -10,7 +10,15 @@ describe JiraTrackerData do
end
describe 'Validations' do
- subject { described_class.new(service: service) }
+ subject do
+ described_class.new(
+ service: service,
+ url: 'http://jira.example.com',
+ api_url: 'http://api-jira.example.com',
+ username: 'jira_username',
+ password: 'jira_password'
+ )
+ end
context 'jira_issue_transition_id' do
it { is_expected.to allow_value(nil).for(:jira_issue_transition_id) }
@@ -36,6 +44,42 @@ describe JiraTrackerData do
it { is_expected.to validate_presence_of(:url) }
it { is_expected.to validate_presence_of(:username) }
it { is_expected.to validate_presence_of(:password) }
+
+ context 'validating urls' do
+ it 'is valid when all fields have required values' do
+ expect(subject).to be_valid
+ end
+
+ it 'is not valid when url is not a valid url' do
+ subject.url = 'not valid'
+
+ expect(subject).not_to be_valid
+ end
+
+ it 'is not valid when api url is not a valid url' do
+ subject.api_url = 'not valid'
+
+ expect(subject).not_to be_valid
+ end
+
+ it 'is not valid when username is missing' do
+ subject.username = nil
+
+ expect(subject).not_to be_valid
+ end
+
+ it 'is not valid when password is missing' do
+ subject.password = nil
+
+ expect(subject).not_to be_valid
+ end
+
+ it 'is valid when api url is a valid url' do
+ subject.api_url = 'http://jira.test.com/api'
+
+ expect(subject).to be_valid
+ end
+ end
end
end
end