mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fix intermittent admin-user-has-no-admin-role error in specs
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
module AuthenticationWorkflow
|
||||
def login_to_admin_section
|
||||
admin_role = Spree::Role.create(:name => 'admin')
|
||||
admin_user = Spree::User.create({
|
||||
admin_role = Spree::Role.find_or_create_by_name!('admin')
|
||||
admin_user = Spree::User.create!({
|
||||
:email => 'admin@ofw.org',
|
||||
:password => 'passw0rd',
|
||||
:password_confirmation => 'passw0rd',
|
||||
:remember_me => false,
|
||||
:persistence_token => 'pass',
|
||||
:login => 'admin@ofw.org',
|
||||
:role_ids => [admin_role.id]})
|
||||
:login => 'admin@ofw.org'})
|
||||
|
||||
admin_user.spree_roles << admin_role
|
||||
|
||||
visit spree.admin_path
|
||||
fill_in 'spree_user_email', :with => 'admin@ofw.org'
|
||||
@@ -20,15 +21,16 @@ module AuthenticationWorkflow
|
||||
# The first user is given the admin role by Spree, so create a dummy user if this is the first
|
||||
create(:user) if Spree::User.admin.empty?
|
||||
|
||||
user_role = Spree::Role.create(:name => 'user')
|
||||
user = Spree::User.create({
|
||||
user_role = Spree::Role.find_or_create_by_name!('user')
|
||||
user = Spree::User.create!({
|
||||
:email => 'someone@ofw.org',
|
||||
:password => 'passw0rd',
|
||||
:password_confirmation => 'passw0rd',
|
||||
:remember_me => false,
|
||||
:persistence_token => 'pass',
|
||||
:login => 'someone@ofw.org',
|
||||
:role_ids => [user_role.id]})
|
||||
:login => 'someone@ofw.org'})
|
||||
|
||||
user.spree_roles << user_role
|
||||
|
||||
visit spree.root_path
|
||||
click_link 'Login'
|
||||
|
||||
Reference in New Issue
Block a user