Skip to content
Browse files

Isolate each component of Spree

This commit contains a whole bunch of changes, from pull request #1296
which will fix #1292.

To understand the gist of the problem, please see the comment threads in

The main bunch of work that was done here was done in two parts: remove all current_user
references from Core and to isolate each component during its testing so
that it is not loading all of Spree for each component, just the
bare-bones components that are needed.

For instance, Core now will only load Core. API will now load API, Auth
and Core. Dash will load Auth and Core. Promo will load Auth and Core.
  • Loading branch information...
1 parent a980448 commit 6dce9ba8b25c3a577255f08be37a2d9bc2a30b99 @radar radar committed Mar 19, 2012
Showing with 164 additions and 173 deletions.
  1. +0 −1 .gitignore
  2. +10 −1 .travis.yml
  3. +1 −46 Gemfile
  4. +0 −8 Rakefile
  5. +6 −0 api/Gemfile
  6. +5 −0 auth/Gemfile
  7. +16 −0 auth/app/controllers/spree/admin/admin_users_controller_decorator.rb
  8. +6 −0 auth/app/overrides/admin_payment_methods_index.rb
  9. 0 {core → auth}/app/views/spree/admin/banners/_gateway.html.erb
  10. +21 −0 auth/spec/requests/admin/users_spec.rb
  11. +51 −0 common_spree_dependencies.rb
  12. +3 −0 core/Gemfile
  13. +1 −1 core/app/controllers/spree/admin/mail_methods_controller.rb
  14. +0 −12 core/app/controllers/spree/admin/users_controller.rb
  15. +0 −3 core/app/models/spree/state_change.rb
  16. +0 −2 core/app/views/spree/admin/payment_methods/index.html.erb
  17. +2 −2 core/app/views/spree/orders/show.html.erb
  18. +6 −6 core/lib/spree/core/testing_support/factories/product_factory.rb
  19. +0 −1 core/spec/controllers/controller_helpers_spec.rb
  20. +0 −4 core/spec/controllers/spree/admin/base_controller_spec.rb
  21. +0 −3 core/spec/controllers/spree/admin/image_settings_controller_spec.rb
  22. +6 −1 core/spec/controllers/spree/admin/mail_methods_controller_spec.rb
  23. +0 −1 core/spec/controllers/spree/admin/orders_controller_spec.rb
  24. +1 −10 core/spec/controllers/spree/admin/products_controller_spec.rb
  25. +0 −4 core/spec/controllers/spree/admin/users_controller_spec.rb
  26. +1 −1 core/spec/controllers/spree/checkout_controller_spec.rb
  27. +0 −1 core/spec/controllers/spree/content_controller_spec.rb
  28. +0 −5 core/spec/controllers/spree/orders_controller_extension_spec.rb
  29. +0 −1 core/spec/controllers/spree/orders_controller_spec.rb
  30. +1 −1 core/spec/lib/search/base_spec.rb
  31. +0 −3 core/spec/models/payment_method_spec.rb
  32. +0 −2 core/spec/requests/admin/configuration/analytics_tracker_spec.rb
  33. +0 −1 core/spec/requests/admin/configuration/general_settings_spec.rb
  34. +0 −2 core/spec/requests/admin/configuration/inventory_settings_spec.rb
  35. +0 −1 core/spec/requests/admin/configuration/mail_methods_spec.rb
  36. +0 −1 core/spec/requests/admin/configuration/payment_methods_spec.rb
  37. +2 −1 core/spec/requests/admin/configuration/shipping_methods_spec.rb
  38. +0 −1 core/spec/requests/admin/configuration/states_spec.rb
  39. +0 −1 core/spec/requests/admin/configuration/tax_categories_spec.rb
  40. +0 −1 core/spec/requests/admin/configuration/tax_rates_spec.rb
  41. +0 −1 core/spec/requests/admin/configuration/taxonomies_spec.rb
  42. +0 −1 core/spec/requests/admin/configuration/zones_spec.rb
  43. +0 −3 core/spec/requests/admin/homepage_spec.rb
  44. +0 −1 core/spec/requests/admin/orders/adjustments_spec.rb
  45. +0 −1 core/spec/requests/admin/orders/customer_details_spec.rb
  46. +0 −1 core/spec/requests/admin/orders/history_spec.rb
  47. +0 −1 core/spec/requests/admin/orders/listing_spec.rb
  48. +0 −3 core/spec/requests/admin/orders/order_details_spec.rb
  49. +0 −1 core/spec/requests/admin/orders/return_authorizations_spec.rb
  50. +0 −1 core/spec/requests/admin/products/edit/images_spec.rb
  51. +0 −2 core/spec/requests/admin/products/edit/products_spec.rb
  52. +0 −1 core/spec/requests/admin/products/edit/taxons_spec.rb
  53. +0 −1 core/spec/requests/admin/products/edit/variants_spec.rb
  54. +0 −1 core/spec/requests/admin/products/option_types_spec.rb
  55. +0 −1 core/spec/requests/admin/products/products_spec.rb
  56. +0 −1 core/spec/requests/admin/products/properties_spec.rb
  57. +0 −2 core/spec/requests/admin/products/prototypes_spec.rb
  58. +0 −1 core/spec/requests/admin/products/variant_spec.rb
  59. +0 −2 core/spec/requests/admin/reports_spec.rb
  60. +0 −16 core/spec/requests/admin/users_spec.rb
  61. +10 −0 core/spec/requests/order_spec.rb
  62. +2 −2 core/spec/spec_helper.rb
  63. +2 −0 core/spec/support/test_gateway.rb
  64. +5 −0 dash/Gemfile
  65. +6 −0 promo/Gemfile
View
1 .gitignore
@@ -23,7 +23,6 @@ db/*.sqlite3*
db/schema.rb
doc/**/*
Gemfile.lock
-*/Gemfile
*/Gemfile.lock
lib/products_index_profiler.rb
log/*.log
View
11 .travis.yml
@@ -5,7 +5,15 @@ env:
- DB=sqlite
- DB=mysql
- DB=postgres
-script: "DISPLAY=:99.0 bundle exec rake"
+script:
+ - "export DISPLAY=:99.0"
+ - "alias set_gemfile='export BUNDLE_GEMFILE=\"`pwd`/Gemfile\"'"
+ - "cd api; set_gemfile; bundle install --quiet; bundle exec rspec spec"
+ - "cd ../auth; set_gemfile; bundle install --quiet; bundle exec rspec spec"
+ - "cd ../core; set_gemfile; bundle install --quiet; bundle exec rspec spec"
+ - "cd ../dash; set_gemfile; bundle install --quiet; bundle exec rspec spec"
+ - "cd ../promo; set_gemfile; bundle install --quiet; bundle exec rspec spec"
+
notifications:
email:
- ryan@spreecommerce.com
@@ -14,6 +22,7 @@ branches:
only:
- 1-0-stable
- master
+ - isolation
rvm:
- 1.8.7
- 1.9.3
View
47 Gemfile
@@ -1,48 +1,3 @@
-source 'http://rubygems.org'
-
-gem 'json'
-gem 'sqlite3'
-gem 'mysql2'
-gem 'pg'
-
-# Gems used only for assets and not required
-# in production environments by default.
-group :assets do
- gem 'sass-rails', "~> 3.2"
- gem 'coffee-rails', "~> 3.2"
-end
-
-group :test do
- gem 'guard'
- gem 'guard-rspec', '~> 0.5.0'
- gem 'rspec-rails', '~> 2.8.0'
- gem 'factory_girl_rails', '~> 1.7.0'
- gem 'email_spec', '~> 1.2.1'
-
- platform :ruby_18 do
- gem 'rcov'
- end
-
- platform :ruby_19 do
- gem 'simplecov'
- end
-
- gem 'ffaker'
- gem 'shoulda-matchers', '~> 1.0.0'
- gem 'capybara'
- gem 'selenium-webdriver', '2.16.0'
- gem 'database_cleaner', '0.7.1'
- gem 'launchy'
-end
-
-# platform :ruby_18 do
-# gem "ruby-debug"
-# end
-
-# platform :ruby_19 do
-# gem "ruby-debug19"
-# end
+eval(File.read(File.dirname(__FILE__) + '/common_spree_dependencies.rb'))
gemspec
-
-
View
8 Rakefile
@@ -20,14 +20,6 @@ end
task :default => :all_tests
-desc "Run all tests for sqlite3 only"
-task :all_tests do
- %w(api auth core dash promo).each do |gem_name|
- puts "########################### #{gem_name} (spec) ###########################"
- sh "cd #{gem_name} && #{$0} spec"
- end
-end
-
desc "Run all tests for all supported databases"
task :ci do
cmd = "bundle update"; puts cmd; system cmd;
View
6 api/Gemfile
@@ -0,0 +1,6 @@
+eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb'))
+
+gem 'spree_core', :path => '../core'
+gem 'spree_auth', :path => '../auth'
+
+gemspec
View
5 auth/Gemfile
@@ -0,0 +1,5 @@
+eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb'))
+
+gem 'spree_core', :path => '../core'
+
+gemspec
View
16 auth/app/controllers/spree/admin/admin_users_controller_decorator.rb
@@ -1,5 +1,21 @@
require File.expand_path('../../base_controller_decorator', __FILE__)
Spree::Admin::UsersController.class_eval do
rescue_from Spree::User::DestroyWithOrdersError, :with => :user_destroy_with_orders_error
+
+ update.after :sign_in_if_change_own_password
+
+ before_filter :load_roles, :only => [:edit, :new, :update, :create]
+
+ private
+
+ def sign_in_if_change_own_password
+ if current_user == @user && @user.password.present?
+ sign_in(@user, :event => :authentication, :bypass => true)
+ end
+ end
+
+ def load_roles
+ @roles = Spree::Role.scoped
+ end
end
View
6 auth/app/overrides/admin_payment_methods_index.rb
@@ -0,0 +1,6 @@
+Deface::Override.new(:virtual_path => "spree/admin/payment_methods/index",
+ :name => "gateway_banner",
+ :insert_after => "#listing_payment_methods",
+ :partial => "spree/admin/banners/gateway")
+
+
View
0 ...ews/spree/admin/banners/_gateway.html.erb → ...ews/spree/admin/banners/_gateway.html.erb
File renamed without changes.
View
21 auth/spec/requests/admin/users_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe 'Users' do
+ before do
+ user = Factory(:admin_user, :email => "c@example.com")
+ sign_in_as!(user)
+ visit spree.admin_users_path
+ end
+
+ context "editing own user" do
+ it "should let me edit own password" do
+ click_link("c@example.com")
+ click_link("Edit")
+ fill_in "user_password", :with => "welcome"
+ fill_in "user_password_confirmation", :with => "welcome"
+ click_button "Update"
+
+ page.should have_content("successfully updated!")
+ end
+ end
+end
View
51 common_spree_dependencies.rb
@@ -0,0 +1,51 @@
+# By placing all of Spree's shared dependencies in this file and then loading
+# it for each component's Gemfile, we can be sure that we're only testing just
+# the one component of Spree.
+source 'http://rubygems.org'
+
+gem 'json'
+gem 'sqlite3'
+gem 'mysql2'
+gem 'pg'
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', "~> 3.2"
+ gem 'coffee-rails', "~> 3.2"
+end
+
+group :test do
+ gem 'guard'
+ gem 'guard-rspec', '~> 0.5.0'
+ gem 'rspec-rails', '~> 2.8.0'
+ gem 'factory_girl_rails', '~> 1.7.0'
+ gem 'email_spec', '~> 1.2.1'
+
+ platform :ruby_18 do
+ gem 'rcov'
+ end
+
+ platform :ruby_19 do
+ gem 'simplecov'
+ end
+
+ gem 'ffaker'
+ gem 'shoulda-matchers', '~> 1.0.0'
+ gem 'capybara'
+ gem 'selenium-webdriver', '2.16.0'
+ gem 'database_cleaner', '0.7.1'
+ gem 'launchy'
+end
+
+# platform :ruby_18 do
+# gem "ruby-debug"
+# end
+
+# platform :ruby_19 do
+# gem "ruby-debug19"
+# end
+
+gemspec
+
+
View
3 core/Gemfile
@@ -0,0 +1,3 @@
+eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb'))
+
+gemspec
View
2 core/app/controllers/spree/admin/mail_methods_controller.rb
@@ -5,7 +5,7 @@ class MailMethodsController < ResourceController
def testmail
@mail_method = Spree::MailMethod.find(params[:id])
- if TestMailer.test_email(@mail_method, current_user).deliver
+ if TestMailer.test_email(@mail_method, respond_to?(:current_user) ? current_user : nil).deliver
flash.notice = t('admin.mail_methods.testmail.delivery_success')
else
flash[:error] = t('admin.mail_methods.testmail.delivery_error')
View
12 core/app/controllers/spree/admin/users_controller.rb
@@ -4,9 +4,6 @@ class UsersController < ResourceController
# http://spreecommerce.com/blog/2010/11/02/json-hijacking-vulnerability/
before_filter :check_json_authenticity, :only => :index
- before_filter :load_roles, :only => [:edit, :new, :update, :create]
-
- update.after :sign_in_if_change_own_password
def index
respond_with(@collection) do |format|
@@ -66,15 +63,6 @@ def json_data
end
end
- def load_roles
- @roles = Role.all
- end
-
- def sign_in_if_change_own_password
- if current_user == @user && @user.password.present?
- sign_in(@user, :event => :authentication, :bypass => true)
- end
- end
end
end
end
View
3 core/app/models/spree/state_change.rb
@@ -9,9 +9,6 @@ def <=>(other)
end
def assign_user
- # if Session.activated? && current_user_session = Session.find
- # self.user_id ||= current_user_session.user.id
- # end
true # don't stop the filters
end
end
View
2 core/app/views/spree/admin/payment_methods/index.html.erb
@@ -37,5 +37,3 @@
<% end %>
</tbody>
</table>
-
-<%= render :partial => 'spree/admin/banners/gateway' %>
View
4 core/app/views/spree/orders/show.html.erb
@@ -13,10 +13,10 @@
<p data-hook="links">
<%= link_to t(:back_to_store), spree.root_path, :class => "button" %>
<% unless params.has_key? :checkout_complete %>
- <% if current_user %>
+ <% if respond_to?(:current_user) && current_user %>
<%= link_to t(:my_account), spree.account_path, :class => "button" %>
<% end %>
<% end %>
</p>
</div>
-</fieldset>
+</fieldset>
View
12 core/lib/spree/core/testing_support/factories/product_factory.rb
@@ -1,21 +1,21 @@
FactoryGirl.define do
sequence(:product_sequence) { |n| "Product ##{n} - #{rand(9999)}" }
- factory :product, :class => Spree::Product do
+ factory :simple_product, :class => Spree::Product do
name { FactoryGirl.generate :product_sequence }
description { Faker::Lorem.paragraphs(1 + Kernel.rand(5)).join("\n") }
-
- # associations:
- tax_category { |r| Spree::TaxCategory.find(:first) || r.association(:tax_category) }
- shipping_category { |r| Spree::ShippingCategory.find(:first) || r.association(:shipping_category) }
-
price 19.99
cost_price 17.00
sku 'ABC'
available_on 1.year.ago
deleted_at nil
end
+ factory :product, :parent => :simple_product do
+ tax_category { |r| Spree::TaxCategory.find(:first) || r.association(:tax_category) }
+ shipping_category { |r| Spree::ShippingCategory.find(:first) || r.association(:shipping_category) }
+ end
+
factory :product_with_option_types, :parent => :product do
after_create { |product| Factory(:product_option_type, :product => product) }
end
View
1 core/spec/controllers/controller_helpers_spec.rb
@@ -6,7 +6,6 @@
describe Spree::ProductsController do
before do
- controller.stub(:set_current_user)
I18n.stub(:available_locales => [:en, :de])
Spree::Config[:default_locale] = nil
Rails.application.config.i18n.default_locale = :de
View
4 core/spec/controllers/spree/admin/base_controller_spec.rb
@@ -11,10 +11,6 @@ def index
end
end
- before do
- controller.stub :current_user => Factory(:admin_user)
- end
-
describe "check alerts" do
it "checks alerts with before_filter" do
controller.should_receive :check_alerts
View
3 core/spec/controllers/spree/admin/image_settings_controller_spec.rb
@@ -1,9 +1,6 @@
require 'spec_helper'
describe Spree::Admin::ImageSettingsController do
- before do
- controller.stub :current_user => Factory(:admin_user)
- end
context "updating image settings" do
it "should be able to update paperclip settings" do
View
7 core/spec/controllers/spree/admin/mail_methods_controller_spec.rb
@@ -5,9 +5,9 @@
let(:mail_method) { mock_model(Spree::MailMethod).as_null_object }
before do
- controller.stub :current_user => Factory(:admin_user)
Spree::Order.stub :find => order
Spree::MailMethod.stub :find => mail_method
+ request.env["HTTP_REFERER"] = "/"
end
context "#create" do
@@ -23,4 +23,9 @@
put :update, {:order_id => "123", :id => "456", :mail_method_parmas => {:environment => "foo"}}
end
end
+
+ it "can trigger testmail without current_user" do
+ post :testmail, :id => Factory(:mail_method).id
+ flash[:error].should_not include("undefined local variable or method `current_user'")
+ end
end
View
1 core/spec/controllers/spree/admin/orders_controller_spec.rb
@@ -5,7 +5,6 @@
let(:order) { mock_model(Spree::Order, :complete? => true, :total => 100) }
before do
- controller.stub :current_user => Factory(:admin_user)
Spree::Order.stub :find_by_number => order
request.env["HTTP_REFERER"] = "http://localhost:3000"
end
View
11 core/spec/controllers/spree/admin/products_controller_spec.rb
@@ -1,10 +1,6 @@
require 'spec_helper'
describe Spree::Admin::ProductsController do
- before do
- controller.stub :current_user => Factory(:admin_user)
- end
-
context "#index" do
it "should not allow JSON request without a valid token" do
controller.should_receive(:protect_against_forgery?).at_least(:once).and_return(true)
@@ -65,12 +61,7 @@
get :new
response.should render_template("admin/products/new")
end
-
- it "should create product" do
- post :create, :product => product_attributes
- response.should redirect_to(spree.edit_admin_product_path(Spree::Product.last))
- end
-
+
it "should create product from prototype" do
post :create, :product => product_attributes.merge(:prototype_id => prototype.id)
product = Spree::Product.last
View
4 core/spec/controllers/spree/admin/users_controller_spec.rb
@@ -1,10 +1,6 @@
require 'spec_helper'
describe Spree::Admin::UsersController do
- before do
- controller.stub :current_user => Factory(:admin_user)
- end
-
context "#index" do
it "should not allow JSON request without a valid token" do
controller.should_receive(:protect_against_forgery?).at_least(:once).and_return(true)
View
2 core/spec/controllers/spree/checkout_controller_spec.rb
@@ -2,7 +2,7 @@
describe Spree::CheckoutController do
let(:order) { mock_model(Spree::Order, :checkout_allowed? => true, :completed? => false, :update_attributes => true, :payment? => false, :insufficient_stock_lines => [], :coupon_code => nil).as_null_object }
- before { controller.stub :current_order => order, :current_user => Factory(:user) }
+ before { controller.stub :current_order => order }
context "#edit" do
View
1 core/spec/controllers/spree/content_controller_spec.rb
@@ -3,7 +3,6 @@
describe Spree::ContentController do
it "should not display a local file" do
- controller.stub :current_user => Factory(:user)
get :show, :path => "../../Gemfile"
response.response_code.should == 404
end
View
5 core/spec/controllers/spree/orders_controller_extension_spec.rb
@@ -1,11 +1,6 @@
require 'spec_helper'
describe Spree::OrdersController do
-
- before do
- controller.stub :current_user => Factory(:user)
- end
-
after do
Spree::OrdersController.clear_overrides!
end
View
1 core/spec/controllers/spree/orders_controller_spec.rb
@@ -6,7 +6,6 @@
let(:order) { mock_model(Spree::Order, :number => "R123", :reload => nil, :save! => true, :coupon_code => nil, :user => user)}
before do
Spree::Order.stub(:find).with(1).and_return(order)
- controller.stub :current_user => user
#ensure no respond_overrides are in effect
if Spree::BaseController.spree_responders[:OrdersController].present?
Spree::BaseController.spree_responders[:OrdersController].clear
View
2 core/spec/lib/search/base_spec.rb
@@ -2,7 +2,7 @@
describe Spree::Core::Search::Base do
- before :each do
+ before do
include ::Spree::ProductFilters
@product1 = Factory(:product, :name => "RoR Mug", :price => 9.00, :on_hand => 1)
@product2 = Factory(:product, :name => "RoR Shirt", :price => 11.00, :on_hand => 1)
View
3 core/spec/models/payment_method_spec.rb
@@ -1,8 +1,5 @@
require 'spec_helper'
-class Spree::Gateway::Test < Spree::Gateway
-end
-
describe Spree::PaymentMethod do
context 'validation' do
View
2 core/spec/requests/admin/configuration/analytics_tracker_spec.rb
@@ -4,7 +4,6 @@
context "index" do
before(:each) do
2.times { Factory(:tracker, :environment => "test") }
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Configuration"
click_link "Analytics Tracker"
@@ -27,7 +26,6 @@
context "create" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Configuration"
click_link "Analytics Tracker"
View
1 core/spec/requests/admin/configuration/general_settings_spec.rb
@@ -2,7 +2,6 @@
describe "General Settings" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Configuration"
click_link "General Settings"
View
2 core/spec/requests/admin/configuration/inventory_settings_spec.rb
@@ -3,8 +3,6 @@
describe "Inventory Settings" do
context "changing settings" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
-
reset_spree_preferences do |config|
config.allow_backorders = true
end
View
1 core/spec/requests/admin/configuration/mail_methods_spec.rb
@@ -2,7 +2,6 @@
describe "Mail Methods" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Configuration"
end
View
1 core/spec/requests/admin/configuration/payment_methods_spec.rb
@@ -2,7 +2,6 @@
describe "Payment Methods" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Configuration"
end
View
3 core/spec/requests/admin/configuration/shipping_methods_spec.rb
@@ -8,14 +8,15 @@
end
before(:each) do
+ # HACK: To work around no email prompting on check out
+ Spree::Order.any_instance.stub(:require_email => false)
PAYMENT_STATES = Spree::Payment.state_machine.states.keys unless defined? PAYMENT_STATES
SHIPMENT_STATES = Spree::Shipment.state_machine.states.keys unless defined? SHIPMENT_STATES
ORDER_STATES = Spree::Order.state_machine.states.keys unless defined? ORDER_STATES
Factory(:payment_method, :environment => 'test')
Factory(:shipping_method, :zone => Spree::Zone.find_by_name('North America'))
@product = Factory(:product, :name => "Mug")
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Configuration"
end
View
1 core/spec/requests/admin/configuration/states_spec.rb
@@ -2,7 +2,6 @@
describe "States" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Configuration"
end
View
1 core/spec/requests/admin/configuration/tax_categories_spec.rb
@@ -2,7 +2,6 @@
describe "Tax Categories" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Configuration"
end
View
1 core/spec/requests/admin/configuration/tax_rates_spec.rb
@@ -4,7 +4,6 @@
let!(:tax_rate) { Factory(:tax_rate, :calculator => stub_model(Spree::Calculator)) }
before do
- sign_in_as! Factory(:admin_user)
visit spree.admin_path
click_link "Configuration"
end
View
1 core/spec/requests/admin/configuration/taxonomies_spec.rb
@@ -2,7 +2,6 @@
describe "Taxonomies" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Configuration"
end
View
1 core/spec/requests/admin/configuration/zones_spec.rb
@@ -2,7 +2,6 @@
describe "Zones" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
Spree::Zone.delete_all
visit spree.admin_path
click_link "Configuration"
View
3 core/spec/requests/admin/homepage_spec.rb
@@ -3,7 +3,6 @@
describe "Homepage" do
context "visiting the homepage" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
end
@@ -38,7 +37,6 @@
context "visiting the products tab" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_products_path
end
@@ -62,7 +60,6 @@
context "visiting the users tab" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_users_path
end
View
1 core/spec/requests/admin/orders/adjustments_spec.rb
@@ -2,7 +2,6 @@
describe "Adjustments" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
order = Factory(:order, :completed_at => "2011-02-01 12:36:15", :number => "R100")
Factory(:adjustment, :adjustable => order)
View
1 core/spec/requests/admin/orders/customer_details_spec.rb
@@ -13,7 +13,6 @@
Factory(:order_with_inventory_unit_shipped, :completed_at => "2011-02-01 12:36:15")
Factory(:user, :email => 'foobar@example.com', :ship_address => Factory(:address), :bill_address => Factory(:address))
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Orders"
within(:css, 'table#listing_orders') { click_link "Edit" }
View
1 core/spec/requests/admin/orders/history_spec.rb
@@ -5,7 +5,6 @@
order = Factory(:order)
order.finalize!
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Orders"
within(:css, 'table#listing_orders tbody tr:nth-child(1)') { click_link "Edit" }
View
1 core/spec/requests/admin/orders/listing_spec.rb
@@ -4,7 +4,6 @@
before(:each) do
Factory(:order, :created_at => Time.now + 1.day, :completed_at => Time.now + 1.day, :number => "R100")
Factory(:order, :created_at => Time.now - 1.day, :completed_at => Time.now - 1.day, :number => "R200")
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
end
View
3 core/spec/requests/admin/orders/order_details_spec.rb
@@ -21,7 +21,6 @@
iu.update_attribute_without_callbacks('state', 'sold')
end
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Orders"
@@ -35,8 +34,6 @@
end
it "should render details properly" do
- sign_in_as!(Factory(:admin_user))
-
order.state = :complete
order.save!
View
1 core/spec/requests/admin/orders/return_authorizations_spec.rb
@@ -4,7 +4,6 @@
let!(:order) { Factory(:completed_order_with_totals) }
before do
- sign_in_as!(Factory(:admin_user))
order.inventory_units.update_all("state = 'shipped'")
Factory(:return_authorization,
:order => order,
View
1 core/spec/requests/admin/products/edit/images_spec.rb
@@ -7,7 +7,6 @@
Factory(:product, :name => 'apache baseball cap', :sku => 'A100', :available_on => "2011-01-01 01:01:01", :count_on_hand => 10)
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Products"
within('table.index tr:nth-child(2)') { click_link "Edit" }
View
2 core/spec/requests/admin/products/edit/products_spec.rb
@@ -8,7 +8,6 @@
Factory(:product, :name => 'Bún thịt nướng', :permalink => 'bun-thit-nuong', :sku => 'A100',
:description => 'lorem ipsum', :available_on => available_on, :count_on_hand => 10)
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link 'Products'
within('table.index tr:nth-child(2)') { click_link 'Edit' }
@@ -31,7 +30,6 @@
Factory(:product, :name => 'Bún thịt nướng', :permalink => 'bun-thit-nuong', :sku => 'A100',
:description => 'lorem ipsum', :available_on => '2011-01-01 01:01:01', :count_on_hand => 10)
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link 'Products'
within('table.index tr:nth-child(2)') { click_link 'Edit' }
View
1 core/spec/requests/admin/products/edit/taxons_spec.rb
@@ -10,7 +10,6 @@
Factory(:product, :name => 'zomg shirt', :sku => 'Z100', :available_on => "2011-01-01 01:01:01")
Spree::Product.update_all :count_on_hand => 10
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Products"
within('table.index tr:nth-child(2)') { click_link "Edit" }
View
1 core/spec/requests/admin/products/edit/variants_spec.rb
@@ -2,7 +2,6 @@
describe "Product Variants" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
end
View
1 core/spec/requests/admin/products/option_types_spec.rb
@@ -2,7 +2,6 @@
describe "Option Types" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Products"
end
View
1 core/spec/requests/admin/products/products_spec.rb
@@ -3,7 +3,6 @@
describe "Products" do
context "as admin user" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
end
View
1 core/spec/requests/admin/products/properties_spec.rb
@@ -2,7 +2,6 @@
describe "Properties" do
before(:each) do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Products"
end
View
2 core/spec/requests/admin/products/prototypes_spec.rb
@@ -29,7 +29,6 @@
p.properties << Spree::Property.find_by_name(prop)
end
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Products"
click_link "Prototypes"
@@ -42,7 +41,6 @@
context "creating a prototype" do
it "should allow an admin to create a new product prototype", :js => true do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Products"
click_link "Prototypes"
View
1 core/spec/requests/admin/products/variant_spec.rb
@@ -9,7 +9,6 @@
Factory(:option_value, :option_type => option.option_type)
end
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Products"
within('table.index tr:nth-child(2)') { click_link "Edit" }
View
2 core/spec/requests/admin/reports_spec.rb
@@ -3,7 +3,6 @@
describe "Reports" do
context "visiting the admin reports page" do
it "should have the right content" do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Reports"
click_link "Sales Total"
@@ -41,7 +40,6 @@
end
it "should allow me to search for reports" do
- sign_in_as!(Factory(:admin_user))
visit spree.admin_path
click_link "Reports"
click_link "Sales Total"
View
16 core/spec/requests/admin/users_spec.rb
@@ -2,7 +2,6 @@
describe "Users" do
before(:each) do
- sign_in_as!(Factory(:admin_user, :email => "c@example.com"))
Factory(:user, :email => "a@example.com")
Factory(:user, :email => "b@example.com")
visit spree.admin_path
@@ -64,19 +63,4 @@
page.should have_content("successfully updated!")
end
end
-
- context "editing own user" do
- before(:each) do
- click_link("c@example.com")
- click_link("Edit")
- end
-
- it "should let me edit own password" do
- fill_in "user_password", :with => "welcome"
- fill_in "user_password_confirmation", :with => "welcome"
- click_button "Update"
-
- page.should have_content("successfully updated!")
- end
- end
end
View
10 core/spec/requests/order_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+
+describe 'orders' do
+ let(:order) { Factory(:order, :shipping_method => Factory(:shipping_method)) }
+
+ it "can visit an order" do
+ # Regression test for current_user call on orders/show
+ lambda { visit spree.order_path(order) }.should_not raise_error
+ end
+end
View
4 core/spec/spec_helper.rb
@@ -96,9 +96,9 @@ def build_option_type_with_values(name, values)
let(:product_attributes) do
# Factory.attributes_for is un-deprecated!
# https://github.com/thoughtbot/factory_girl/issues/274#issuecomment-3592054
- Factory.attributes_for(:product)
+ Factory.attributes_for(:simple_product)
end
-
+
let(:prototype) do
size = build_option_type_with_values("size", %w(Small Medium Large))
Factory(:prototype, :name => "Size", :option_types => [ size ])
View
2 core/spec/support/test_gateway.rb
@@ -0,0 +1,2 @@
+class Spree::Gateway::Test < Spree::Gateway
+end
View
5 dash/Gemfile
@@ -0,0 +1,5 @@
+eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb'))
+
+gem 'spree_core', :path => '../core'
+
+gemspec
View
6 promo/Gemfile
@@ -0,0 +1,6 @@
+eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb'))
+
+gem 'spree_core', :path => '../core'
+gem 'spree_auth', :path => '../auth'
+
+gemspec

0 comments on commit 6dce9ba

Please sign in to comment.
Something went wrong with that request. Please try again.