mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
can specify attributes for create_enterpise_user
This commit is contained in:
@@ -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) }
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user