can specify attributes for create_enterpise_user

This commit is contained in:
Rob Harrington
2014-09-25 11:56:18 +10:00
parent ed91cd6463
commit 9520eeeb15
3 changed files with 7 additions and 11 deletions

View File

@@ -89,7 +89,7 @@ feature %q{
let!(:d1) { create(:distributor_enterprise) }
let!(:d2) { create(:distributor_enterprise) }
let!(:d3) { create(:distributor_enterprise) }
let(:enterprise_user) { create_enterprise_user([d1]) }
let(:enterprise_user) { create_enterprise_user( enterprises: [d1] ) }
let!(:er1) { create(:enterprise_relationship, parent: d1, child: d2) }
let!(:er2) { create(:enterprise_relationship, parent: d2, child: d1) }

View File

@@ -10,8 +10,8 @@ feature %q{
context "Permissions for different reports" do
context "As an enterprise user" do
let(:user) do
create_enterprise_user([
create(:distributor_enterprise)
create_enterprise_user(enterprises: [
create(:distributor_enterprise)
])
end
it "should not show the Sales Total report" do
@@ -99,7 +99,7 @@ feature %q{
let(:shipping_instructions) { "pick up on thursday please!" }
let(:order1) { create(:order, :distributor => distributor, :bill_address => bill_address, :special_instructions => shipping_instructions) }
let(:order2) { create(:order, :distributor => distributor, :bill_address => bill_address, :special_instructions => shipping_instructions) }
before do
Timecop.travel(Time.zone.local(2013, 4, 25, 14, 0, 0)) { order1.finalize! }
Timecop.travel(Time.zone.local(2013, 4, 25, 16, 0, 0)) { order2.finalize! }
@@ -144,7 +144,7 @@ feature %q{
variant_2.update_column(:count_on_hand, 20)
product_2.master.update_column(:count_on_hand, 9)
variant_1.option_values = [create(:option_value, :presentation => "Test")]
login_to_admin_section
click_link 'Reports'
@@ -165,4 +165,3 @@ feature %q{
end
end
end

View File

@@ -37,12 +37,9 @@ module AuthenticationWorkflow
visit spree.admin_path
end
def create_enterprise_user(enterprises = [])
new_user = create(:user, password: 'blahblah', :password_confirmation => 'blahblah')
def create_enterprise_user( attrs = {} )
new_user = create(:user, attrs)
new_user.spree_roles = [] # for some reason unbeknown to me, this new user gets admin permissions by default.
for enterprise in enterprises do
new_user.enterprise_roles.build(enterprise: enterprise).save
end
new_user.save
new_user
end