diff --git a/spec/request/distributors_spec.rb b/spec/request/distributors_spec.rb new file mode 100644 index 0000000000..4ddb377093 --- /dev/null +++ b/spec/request/distributors_spec.rb @@ -0,0 +1,39 @@ +require "spec_helper" + +feature %q{ + As an administration + I want manage the distributors of products +} do + include AuthenticationWorkflow + + background do + end + + context "Given I am setting up distributors" do + scenario "I should be able to create a new distributor" do + login_to_admin_section + + click_link 'Distributors' + click_link 'New Distributor' + + fill_in 'distributor_name', :with => 'Eaterprises' + fill_in 'distributor_description', :with => 'Connecting farmers and eaters' + fill_in 'distributor_contact', :with => 'Kirsten or Ren' + fill_in 'distributor_phone', :with => '0413 897 321' + fill_in 'distributor_pickup_address', :with => '35 Ballantyne St' + fill_in 'distributor_city', :with => 'Thornbury' + fill_in 'distributor_post_code', :with => '3072' + select('Australia', :from => 'distributor_country_id') + select('Victoria', :from => 'distributor_state_id') + fill_in 'distributor_pickup_times', :with => 'Thursday, 22nd Feb, 6 - 9 PM. Friday, 23nd Feb, 6 - 9 PM' + fill_in 'distributor_email', :with => 'info@eaterprises.com.au' + fill_in 'distributor_url', :with => 'http://eaterprises.com.au' + fill_in 'distributor_abn', :with => '09812309823' + fill_in 'distributor_acn', :with => '' + + click_button 'Create' + + find('.flash').text.strip.should == 'Distributor "Eaterprises" has been successfully created!' + end + end +end diff --git a/spec/request/suppliers_spec.rb b/spec/request/suppliers_spec.rb index 09dd6e8e28..a19be159e3 100644 --- a/spec/request/suppliers_spec.rb +++ b/spec/request/suppliers_spec.rb @@ -4,28 +4,14 @@ feature %q{ As an administration I want manage the suppliers of products } do - # include AuthenticationWorkflow - # include WebHelper + include AuthenticationWorkflow background do end context "Given I am setting up suppliers" do scenario "I should be able to create a new supplier" do - admin_role = Spree::Role.create(: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]}) - - visit spree.admin_path - fill_in 'user_email', :with => 'admin@ofw.org' - fill_in 'user_password', :with => 'passw0rd' - click_button 'Login' + login_to_admin_section click_link 'Suppliers' click_link 'New Supplier' diff --git a/spec/support/request/authentication_workflow.rb b/spec/support/request/authentication_workflow.rb new file mode 100644 index 0000000000..9208b53b0b --- /dev/null +++ b/spec/support/request/authentication_workflow.rb @@ -0,0 +1,18 @@ +module AuthenticationWorkflow + def login_to_admin_section + admin_role = Spree::Role.create(: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]}) + + visit spree.admin_path + fill_in 'user_email', :with => 'admin@ofw.org' + fill_in 'user_password', :with => 'passw0rd' + click_button 'Login' + end +end