From 705e247eb8defe4baa16cc1780ba0b1cf8a8e86e Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Fri, 2 May 2014 12:41:04 +1000 Subject: [PATCH] Tweaking the bulk order management spec again --- spec/features/admin/bulk_order_management_spec.rb | 4 ++-- spec/support/request/authentication_workflow.rb | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/spec/features/admin/bulk_order_management_spec.rb b/spec/features/admin/bulk_order_management_spec.rb index 61842ff48c..0cfb211178 100644 --- a/spec/features/admin/bulk_order_management_spec.rb +++ b/spec/features/admin/bulk_order_management_spec.rb @@ -8,8 +8,7 @@ feature %q{ include AuthorizationHelpers include WebHelper - before(:all) { Spree::Ability.register_ability(AuthorizationHelpers::Request::SuperAbility) } - after(:all) { Spree::Ability.remove_ability(AuthorizationHelpers::Request::SuperAbility) } + stub_authorization! before :all do @default_wait_time = Capybara.default_wait_time @@ -36,6 +35,7 @@ feature %q{ it "displays a message when number of line items is zero" do visit '/admin/orders/bulk_management' page.should have_text "No matching line items found." + end context "displaying the list of line items" do diff --git a/spec/support/request/authentication_workflow.rb b/spec/support/request/authentication_workflow.rb index 53e6a48dbb..da02535646 100644 --- a/spec/support/request/authentication_workflow.rb +++ b/spec/support/request/authentication_workflow.rb @@ -1,5 +1,4 @@ module AuthenticationWorkflow - def quick_login_as(user) ApplicationController.any_instance.stub(:spree_current_user).and_return user ApplicationController.any_instance.stub(:current_api_user).and_return user @@ -19,6 +18,11 @@ module AuthenticationWorkflow admin_user end + def stub_authorization! + before(:all) { Spree::Ability.register_ability(AuthorizationHelpers::Request::SuperAbility) } + after(:all) { Spree::Ability.remove_ability(AuthorizationHelpers::Request::SuperAbility) } + end + def login_to_admin_section admin_role = Spree::Role.find_or_create_by_name!('admin') admin_user = create(:user, @@ -70,3 +74,7 @@ module AuthenticationWorkflow click_button 'Login' end end + +RSpec.configure do |config| + config.extend AuthenticationWorkflow, :type => :feature +end