Commit 22ccc1d7 authored by jejacks0n's avatar jejacks0n

Improves the expect_next spec implementation

parent 65836d5f
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe "User registration", :js, :saas do RSpec.describe "User registration", :js, :saas do
include AfterNextHelpers
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
before do before do
...@@ -155,24 +157,22 @@ RSpec.describe "User registration", :js, :saas do ...@@ -155,24 +157,22 @@ RSpec.describe "User registration", :js, :saas do
before do before do
click_button class: 'gl-toggle' click_button class: 'gl-toggle'
expect_next_instance_of(GitlabSubscriptions::CreateLeadService) do |service| expect_next(GitlabSubscriptions::CreateLeadService).to receive(:execute).with(
expect(service).to receive(:execute).with( trial_user: ActionController::Parameters.new(
trial_user: ActionController::Parameters.new( company_name: '',
company_name: '', company_size: '',
company_size: '', phone_number: '',
phone_number: '', country: '',
country: '', website_url: '',
website_url: '', work_email: user.email,
work_email: user.email, uid: user.id,
uid: user.id, setup_for_company: true,
setup_for_company: true, skip_email_confirmation: true,
skip_email_confirmation: true, gitlab_com_trial: true,
gitlab_com_trial: true, provider: 'gitlab',
provider: 'gitlab', newsletter_segment: true
newsletter_segment: true ).permit!
).permit! ).and_return(success: true)
).and_return(success: true)
end
click_on 'Continue' click_on 'Continue'
end end
...@@ -183,18 +183,16 @@ RSpec.describe "User registration", :js, :saas do ...@@ -183,18 +183,16 @@ RSpec.describe "User registration", :js, :saas do
fill_in 'group_name', with: 'Test Group' fill_in 'group_name', with: 'Test Group'
fill_in 'blank_project_name', with: 'Test Project' fill_in 'blank_project_name', with: 'Test Project'
expect_next_instance_of(GitlabSubscriptions::CreateLeadService) do |service| expect_next(GitlabSubscriptions::CreateLeadService).to receive(:execute).with(
expect(service).to receive(:execute).with( uid: user.id,
uid: user.id, trial_user:
trial_user: ActionController::Parameters.new(
ActionController::Parameters.new( namespace_id: Namespace.maximum(:id).to_i + 1,
namespace_id: Namespace.maximum(:id).to_i + 1, trial_entity: 'company',
trial_entity: 'company', gitlab_com_trial: true,
gitlab_com_trial: true, sync_to_gl: true
sync_to_gl: true ).permit!
).permit! ).and_return(success: true)
).and_return(success: true)
end
click_on 'Create project' click_on 'Create project'
......
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