Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Dependency cleanup. Spec fixes for 1.2 + new auth system.

  • Loading branch information...
commit 1d7f99c5bd784399ddc7b0334b611cdb119c4d7a 1 parent c011d8b
@iloveitaly iloveitaly authored radar committed
View
14 Gemfile
@@ -1,14 +1,4 @@
source 'http://rubygems.org'
-
-group :test do
- gem 'pry'
- gem 'rspec-rails', '~> 2.9.0'
- gem 'factory_girl', '~> 2.6.4'
- gem 'factory_girl_rails', '~> 1.7'
- gem 'sqlite3'
- gem 'faker'
- gem 'shoulda-matchers'
-end
-
-gem 'spree', :git => 'https://github.com/spree/spree', :branch => "1-1-stable"
gemspec
+
+gem 'spree', '~> 1.2'
View
2  lib/spree_volume_pricing/engine.rb
@@ -1,5 +1,7 @@
module SpreeVolumePricing
class Engine < Rails::Engine
+ require 'spree/core'
+ isolate_namespace Spree
engine_name 'spree_volume_pricing'
def self.activate
View
11 spec/controllers/spree/admin/variants_controller_spec.rb
@@ -1,18 +1,13 @@
require 'spec_helper'
describe Spree::Admin::VariantsController do
- let(:user) { FactoryGirl.create :user }
- before do
- controller.stub :spree_current_user => user
- user.stub :has_role? => true
- controller.stub :admin_variants_url => "/"
- end
+ stub_authorization!
describe "PUT #update" do
it "creates a volume price" do
variant = FactoryGirl.create :variant
- lambda do
+ expect do
spree_put :update,
:product_id => variant.product.permalink,
:id => variant.id,
@@ -27,7 +22,7 @@
}
}
}
- end.should change(variant.volume_prices, :count).by(1)
+ end.to change(variant.volume_prices, :count).by(1)
end
end
end
View
13 spec/requests/volume_pricing_admin_spec.rb
@@ -1,13 +0,0 @@
-# TODO finish request spec here... can't figure out how to do authentication
-
-# require 'spec_helper'
-
-# describe "Volume Pricing Admin" do
-# before { stub_authentication! }
-
-# it 'should be able to add volume pricing', :js => true do
-# product = FactoryGirl.create :product
-# visit spree.volume_prices_admin_product_variant_path(product, product.master)
-# # check for proper page rendering
-# end
-# end
View
7 spec/spec_helper.rb
@@ -9,6 +9,7 @@
require 'spree/core/testing_support/env'
require 'spree/core/testing_support/controller_requests'
require 'spree/core/url_helpers'
+# require 'spree/core/testing_support/authorization_helpers'
# include local factories
Dir["#{File.dirname(__FILE__)}/factories/**/*.rb"].each do |f|
@@ -18,12 +19,12 @@
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
-Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
- config.use_transactional_fixtures = true
+ config.use_transactional_fixtures = false
config.include FactoryGirl::Syntax::Methods
config.include Spree::Core::UrlHelpers
- config.include Spree::Core::TestingSupport::ControllerRequests, :type => :controller
+ config.include Spree::Core::TestingSupport::ControllerRequests
end
View
33 spec/support/authorization_helpers.rb
@@ -0,0 +1,33 @@
+# copy of this helper until 1.2.1
+# https://github.com/spree/spree/commit/61d1aafa78bc278efe041c7b50a3202e831d0208
+
+module AuthorizationHelpers
+ module Controller
+ def stub_authorization!
+ before do
+ controller.should_receive(:authorize!).twice.and_return(true)
+ end
+ end
+ end
+
+ module Request
+ class SuperAbility
+ include CanCan::Ability
+
+ def initialize(user)
+ # allow anyone to perform index on Order
+ can :manage, :all
+ end
+ end
+
+ def stub_authorization!
+ before(:all) { Spree::Ability.register_ability(AuthorizationHelpers::Request::SuperAbility) }
+ after(:all) { Spree::Ability.remove_ability(AuthorizationHelpers::Request::SuperAbility) }
+ end
+ end
+end
+
+RSpec.configure do |config|
+ config.extend AuthorizationHelpers::Controller, :type => :controller
+ config.extend AuthorizationHelpers::Request, :type => :request
+end
View
5 spree_volume_pricing.gemspec
@@ -21,7 +21,6 @@ Gem::Specification.new do |s|
s.add_development_dependency('capybara')
s.add_development_dependency('ffaker')
s.add_development_dependency('shoulda-matchers')
- s.add_development_dependency('rspec-rails', '~> 2.11')
- s.add_development_dependency('factory_girl', '~> 2.6')
-
+ s.add_development_dependency('rspec-rails', '~> 2.9.0')
+ s.add_development_dependency('factory_girl_rails', '~> 1.7.0')
end
Please sign in to comment.
Something went wrong with that request. Please try again.