Commit c2829d40 authored by Arturo Herrero's avatar Arturo Herrero

Add unit test for service methods

This covers external_issue_tracker? and external_wiki? methods.
parent bb96902e
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Service do RSpec.describe Service do
using RSpec::Parameterized::TableSyntax
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) }
...@@ -15,8 +17,6 @@ RSpec.describe Service do ...@@ -15,8 +17,6 @@ RSpec.describe Service do
end end
describe 'validations' do describe 'validations' do
using RSpec::Parameterized::TableSyntax
it { is_expected.to validate_presence_of(:type) } it { is_expected.to validate_presence_of(:type) }
where(:project_id, :group_id, :template, :instance, :valid) do where(:project_id, :group_id, :template, :instance, :valid) do
...@@ -863,4 +863,32 @@ RSpec.describe Service do ...@@ -863,4 +863,32 @@ RSpec.describe Service do
end end
end end
end end
describe '#external_issue_tracker?' do
where(:category, :active, :result) do
:issue_tracker | true | true
:issue_tracker | false | false
:common | true | false
end
with_them do
it 'returns the right result' do
expect(build(:service, category: category, active: active).external_issue_tracker?).to eq(result)
end
end
end
describe '#external_wiki?' do
where(:type, :active, :result) do
'ExternalWikiService' | true | true
'ExternalWikiService' | false | false
'SlackService' | true | false
end
with_them do
it 'returns the right result' do
expect(build(:service, type: type, active: active).external_wiki?).to eq(result)
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