diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/integrations_controller_spec.rb | 20 | ||||
-rw-r--r-- | spec/models/integration_spec.rb | 12 | ||||
-rw-r--r-- | spec/services/integrations/merge_request_service_spec.rb | 11 | ||||
-rw-r--r-- | spec/services/integrations/pipeline_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/integrations/project_snippet_service_spec.rb | 6 |
5 files changed, 29 insertions, 22 deletions
diff --git a/spec/controllers/integrations_controller_spec.rb b/spec/controllers/integrations_controller_spec.rb index 3aad02da4cb..53f4619c983 100644 --- a/spec/controllers/integrations_controller_spec.rb +++ b/spec/controllers/integrations_controller_spec.rb @@ -6,16 +6,16 @@ RSpec.describe IntegrationsController, type: :controller do let(:slack_params) do { format: :json, - "token"=>"24randomcharacters", - "team_id"=>"T123456T9", - "team_domain"=>"mepmep", - "channel_id"=>"C12345678", - "channel_name"=>"general", - "user_id"=>"U12345678", - "user_name"=>"mep", - "command"=>"/issue", - "text"=>"3", - "response_url"=>"https://hooks.slack.com/commands/T123456T9/79958163905/siWqY7Qtx8z0zWFsXBod9VEy" + "token" => "24randomcharacters", + "team_id" => "T123456T9", + "team_domain" => "mepmep", + "channel_id" => "C12345678", + "channel_name" => "general", + "user_id" => "U12345678", + "user_name" => "mep", + "command" => "/issue", + "text" => "3", + "response_url" => "https://hooks.slack.com/commands/T123456T9/79958163905/siWqY7Qtx8z0zWFsXBod9VEy" } end diff --git a/spec/models/integration_spec.rb b/spec/models/integration_spec.rb index aae8d31dae1..b8aa4acb211 100644 --- a/spec/models/integration_spec.rb +++ b/spec/models/integration_spec.rb @@ -1,5 +1,15 @@ require 'rails_helper' RSpec.describe Integration, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + subject { create(:integration) } + + describe 'associations' do + it { is_expected.to belong_to(:project) } + end + + describe 'validation' do + it { is_expected.to validate_presence_of(:project) } + it { is_expected.to validate_presence_of(:name) } + it { is_expected.to validate_presence_of(:external_token) } + end end diff --git a/spec/services/integrations/merge_request_service_spec.rb b/spec/services/integrations/merge_request_service_spec.rb index 9e4e5f21951..d42829ecd24 100644 --- a/spec/services/integrations/merge_request_service_spec.rb +++ b/spec/services/integrations/merge_request_service_spec.rb @@ -12,19 +12,16 @@ describe Integrations::MergeRequestService, services: true do let(:mr) { create(:merge_request, source_project: project) } it 'returns the issue by ID' do - expect(subject[:text]).to match /!\d+\s#{Regexp.quote(mr.title)}/ + expect(subject[:attachments].first[:fallback]).to eq mr.title end end context 'when searching with only one result' do - let(:title) { 'Aint this a String?' } - let(:params) { { text: title[2..7] } } + let(:params) { { text: merge_request.title[2..7] } } + let!(:merge_request) { create(:merge_request, source_project: project) } it 'returns the search results' do - create(:merge_request, source_project: project, title: title) - create(:merge_request, source_project: project) - - expect(subject[:text]).to match /!\d+\sAint\sthis/ + expect(subject[:attachments].first[:fallback]).to eq merge_request.title end end end diff --git a/spec/services/integrations/pipeline_service_spec.rb b/spec/services/integrations/pipeline_service_spec.rb index 1e4a2561f8c..19e0d5ed5be 100644 --- a/spec/services/integrations/pipeline_service_spec.rb +++ b/spec/services/integrations/pipeline_service_spec.rb @@ -12,7 +12,7 @@ describe Integrations::PipelineService, services: true do let(:params) { { text: pipeline.ref } } it 'returns the pipeline by ID' do - expect(subject[:text]).to match /#\d+\ Pipeline\ for\ #{pipeline.ref}: #{pipeline.status}/ + expect(subject[:attachments].first[:fallback]).to match /Pipeline\ for\ #{pipeline.ref}: #{pipeline.status}/ end end end diff --git a/spec/services/integrations/project_snippet_service_spec.rb b/spec/services/integrations/project_snippet_service_spec.rb index 8d2a16ac815..6efb4a09152 100644 --- a/spec/services/integrations/project_snippet_service_spec.rb +++ b/spec/services/integrations/project_snippet_service_spec.rb @@ -9,10 +9,10 @@ describe Integrations::ProjectSnippetService, services: true do describe '#execute' do context 'looking up by ID' do let(:snippet) { create(:project_snippet, project: project) } - let(:params) { { text: snippet.id } } + let(:params) { { text: "$#{snippet.id}" } } - it 'returns the issue by ID' do - expect(subject[:text]).to match /\$\d+\s#{Regexp.quote(snippet.title)}/ + it 'returns the snippet by ID' do + expect(subject[:attachments].first[:fallback]).to eq snippet.title end end end |