diff --git a/test/functional/phases_controller_test.rb b/test/functional/phases_controller_test.rb index 7bd9ff9..efbbc54 100644 --- a/test/functional/phases_controller_test.rb +++ b/test/functional/phases_controller_test.rb @@ -8,8 +8,8 @@ # Get the first Org Admin @user = org_admin_from(Template.first.org) - @plan = Plan.create(template: @template, title: 'Test Plan', - roles: [Role.new(user: @user, creator: true)]) + @plan = Plan.create!(template: @template, title: 'Test Plan', + roles: [Role.new(user: @user, creator: true)]) end # TODO: The following methods SHOULD replace the old 'admin_' prefixed methods. The routes file already has diff --git a/test/test_helper.rb b/test/test_helper.rb index cb11b41..ff0125b 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -37,14 +37,13 @@ # ---------------------------------------------------------------------- def org_admin_from(org) usr = org.users.select{|u| u.can_org_admin?}.first - usr = User.new(email: "admin@example.com", firstname: "Org", surname: "Admin", - language: Language.find_by(abbreviation: FastGettext.locale), - password: "password123", password_confirmation: "password123", - perms: Perm.where.not(name: ['admin', 'add_organisations', 'change_org_affiliation', 'grant_api_to_orgs']), - org: org, accept_terms: true, confirmed_at: Time.zone.now) if usr.nil? - -puts "VALID: #{usr.valid?} - #{usr.errors.collect{|e,m| "#{e} - #{m}"}.join(", ")}" - + if usr.nil? + usr = User.create!(email: "admin-#{org.abbreviation.downcase}@example.com", firstname: "Org", surname: "Admin", + language: Language.find_by(abbreviation: FastGettext.locale), + password: "password123", password_confirmation: "password123", + perms: Perm.where.not(name: ['admin', 'add_organisations', 'change_org_affiliation', 'grant_api_to_orgs']), + org: org, accept_terms: true, confirmed_at: Time.zone.now) + end usr end