diff --git a/spec/controllers/api/v1/accounts/integrations/linear_controller_spec.rb b/spec/controllers/api/v1/accounts/integrations/linear_controller_spec.rb index 5f512b2bd..5e258ebd7 100644 --- a/spec/controllers/api/v1/accounts/integrations/linear_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/integrations/linear_controller_spec.rb @@ -119,7 +119,7 @@ RSpec.describe 'Linear Integration API', type: :request do let(:created_issue) { { data: { identifier: 'ENG-123', title: 'Sample Issue' } } } it 'returns the created issue' do - allow(processor_service).to receive(:create_issue).with(issue_params.stringify_keys, agent).and_return(created_issue) + allow(processor_service).to receive(:create_issue).and_return(created_issue) post "/api/v1/accounts/#{account.id}/integrations/linear/create_issue", params: issue_params, @@ -128,10 +128,14 @@ RSpec.describe 'Linear Integration API', type: :request do expect(response).to have_http_status(:ok) expect(response.body).to include('Sample Issue') + expect(processor_service).to have_received(:create_issue) do |params, user| + expect(params.to_h).to eq(issue_params.stringify_keys) + expect(user).to eq(agent) + end end it 'creates activity message when conversation is provided' do - allow(processor_service).to receive(:create_issue).with(issue_params.stringify_keys, agent).and_return(created_issue) + allow(processor_service).to receive(:create_issue).and_return(created_issue) expect do post "/api/v1/accounts/#{account.id}/integrations/linear/create_issue", @@ -145,12 +149,16 @@ RSpec.describe 'Linear Integration API', type: :request do message_type: :activity, content: "Linear issue ENG-123 was created by #{agent.name}" }) + expect(processor_service).to have_received(:create_issue) do |params, user| + expect(params.to_h).to eq(issue_params.stringify_keys) + expect(user).to eq(agent) + end end end context 'when issue creation fails' do it 'returns error message and does not create activity message' do - allow(processor_service).to receive(:create_issue).with(issue_params.stringify_keys, agent).and_return(error: 'error message') + allow(processor_service).to receive(:create_issue).and_return(error: 'error message') expect do post "/api/v1/accounts/#{account.id}/integrations/linear/create_issue", @@ -161,6 +169,10 @@ RSpec.describe 'Linear Integration API', type: :request do expect(response).to have_http_status(:unprocessable_entity) expect(response.body).to include('error message') + expect(processor_service).to have_received(:create_issue) do |params, user| + expect(params.to_h).to eq(issue_params.stringify_keys) + expect(user).to eq(agent) + end end end end