mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-05 02:41:33 +00:00
Merge pull request #11177 from cyrillefr/Registration_of_an_enterprise_name_already_taken_stops_registration_process
Registration of an enterprise name already taken stops registration process
This commit is contained in:
@@ -9,10 +9,9 @@ angular.module('Darkswarm').controller "RegistrationFormCtrl", ($scope, Registra
|
||||
$scope.create = (form) ->
|
||||
if ($scope.valid(form))
|
||||
$scope.disableButton()
|
||||
EnterpriseRegistrationService.create().then(() ->
|
||||
EnterpriseRegistrationService.create($scope.enableButton).then(() ->
|
||||
$scope.enableButton()
|
||||
)
|
||||
end
|
||||
|
||||
$scope.update = (nextStep, form) ->
|
||||
EnterpriseRegistrationService.update(nextStep) if $scope.valid(form)
|
||||
|
||||
@@ -159,6 +159,54 @@ describe "Registration" do
|
||||
expect(page).to have_checked_field "enterprise_visible_only_through_links"
|
||||
end
|
||||
|
||||
context "Enterprise name is already taken" do
|
||||
let(:owner) do
|
||||
Spree::User.create!(email: "penny.profile@example.org", password: "cannotbeblank")
|
||||
end
|
||||
|
||||
before do
|
||||
address = Spree::Address.create!(firstname: 'John', lastname: 'Doe',
|
||||
address1: '1400 Sesame street', zipcode: '3070',
|
||||
city: 'Southcote', phone: '12 3456 7890',
|
||||
country_id: 1, state_id: 1, company: 'unused')
|
||||
Enterprise.create(name: 'My Awesome Enterprise', address:, owner:)
|
||||
end
|
||||
|
||||
it "checks that button after failure is still enabled" do
|
||||
visit registration_path
|
||||
switch_to_login_tab
|
||||
|
||||
fill_in "Email", with: user.email
|
||||
fill_in "Password", with: user.password
|
||||
click_button "Login"
|
||||
click_button "Let's get started!"
|
||||
|
||||
fill_in 'enterprise_name', with: "My Awesome Enterprise"
|
||||
fill_in 'enterprise_address', with: '123 Abc Street'
|
||||
fill_in 'enterprise_city', with: 'Northcote'
|
||||
fill_in 'enterprise_zipcode', with: '3070'
|
||||
select 'Vic', from: 'enterprise_state'
|
||||
click_button "Continue"
|
||||
|
||||
fill_in 'enterprise_contact', with: 'Saskia Munroe'
|
||||
fill_in 'enterprise_phone', with: '12 3456 7890'
|
||||
|
||||
click_button "Continue"
|
||||
click_button "Create Profile"
|
||||
click_link "producer-panel"
|
||||
alert_text = <<~TEXT.strip
|
||||
Name has already been taken. If this is your enterprise and you would \
|
||||
like to claim ownership, or if you would like to trade with this \
|
||||
enterprise please contact the current manager of this profile at \
|
||||
penny.profile@example.org.
|
||||
TEXT
|
||||
accept_alert(alert_text) do
|
||||
click_button "Create Profile"
|
||||
end
|
||||
expect(page).to have_button "Create Profile", disabled: false
|
||||
end
|
||||
end
|
||||
|
||||
context "when the user has no more remaining enterprises" do
|
||||
before do
|
||||
user.update(enterprise_limit: 0)
|
||||
|
||||
Reference in New Issue
Block a user