diff --git a/.gitignore b/.gitignore index 413d317a99d..179c4166b94 100644 --- a/.gitignore +++ b/.gitignore @@ -23,7 +23,6 @@ db/*.sqlite3* db/schema.rb doc/**/* Gemfile.lock -*/Gemfile */Gemfile.lock lib/products_index_profiler.rb log/*.log diff --git a/.travis.yml b/.travis.yml index c051725967d..cb73ed9a661 100644 --- a/.travis.yml +++ b/.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 diff --git a/Gemfile b/Gemfile index 22624ae011a..c74b2a60ce2 100644 --- a/Gemfile +++ b/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 - - diff --git a/Rakefile b/Rakefile index 51deb04decb..df4b688bd1a 100644 --- a/Rakefile +++ b/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; diff --git a/api/Gemfile b/api/Gemfile new file mode 100644 index 00000000000..7a36159d160 --- /dev/null +++ b/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 diff --git a/auth/Gemfile b/auth/Gemfile new file mode 100644 index 00000000000..af51fbf0c11 --- /dev/null +++ b/auth/Gemfile @@ -0,0 +1,5 @@ +eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb')) + +gem 'spree_core', :path => '../core' + +gemspec diff --git a/auth/app/controllers/spree/admin/admin_users_controller_decorator.rb b/auth/app/controllers/spree/admin/admin_users_controller_decorator.rb index 4b07f714611..aadfcf14022 100644 --- a/auth/app/controllers/spree/admin/admin_users_controller_decorator.rb +++ b/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 diff --git a/auth/app/overrides/admin_payment_methods_index.rb b/auth/app/overrides/admin_payment_methods_index.rb new file mode 100644 index 00000000000..e5044a7fa1a --- /dev/null +++ b/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") + + diff --git a/core/app/views/spree/admin/banners/_gateway.html.erb b/auth/app/views/spree/admin/banners/_gateway.html.erb similarity index 100% rename from core/app/views/spree/admin/banners/_gateway.html.erb rename to auth/app/views/spree/admin/banners/_gateway.html.erb diff --git a/auth/spec/requests/admin/users_spec.rb b/auth/spec/requests/admin/users_spec.rb new file mode 100644 index 00000000000..fd84c87f55b --- /dev/null +++ b/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 diff --git a/common_spree_dependencies.rb b/common_spree_dependencies.rb new file mode 100644 index 00000000000..98df198cf36 --- /dev/null +++ b/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 + + diff --git a/core/Gemfile b/core/Gemfile new file mode 100644 index 00000000000..3e1947400c8 --- /dev/null +++ b/core/Gemfile @@ -0,0 +1,3 @@ +eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb')) + +gemspec diff --git a/core/app/controllers/spree/admin/mail_methods_controller.rb b/core/app/controllers/spree/admin/mail_methods_controller.rb index 5cd5e0b0a4a..a081ae6f4bf 100644 --- a/core/app/controllers/spree/admin/mail_methods_controller.rb +++ b/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') diff --git a/core/app/controllers/spree/admin/users_controller.rb b/core/app/controllers/spree/admin/users_controller.rb index 460087b8787..88db640b8d6 100644 --- a/core/app/controllers/spree/admin/users_controller.rb +++ b/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 diff --git a/core/app/models/spree/state_change.rb b/core/app/models/spree/state_change.rb index 465d70c8b3e..92f8054b83a 100644 --- a/core/app/models/spree/state_change.rb +++ b/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 diff --git a/core/app/views/spree/admin/payment_methods/index.html.erb b/core/app/views/spree/admin/payment_methods/index.html.erb index a2d905231b9..150cd0a0224 100644 --- a/core/app/views/spree/admin/payment_methods/index.html.erb +++ b/core/app/views/spree/admin/payment_methods/index.html.erb @@ -37,5 +37,3 @@ <% end %> - -<%= render :partial => 'spree/admin/banners/gateway' %> \ No newline at end of file diff --git a/core/app/views/spree/orders/show.html.erb b/core/app/views/spree/orders/show.html.erb index ea18deabdaf..bdc1910d43d 100644 --- a/core/app/views/spree/orders/show.html.erb +++ b/core/app/views/spree/orders/show.html.erb @@ -13,10 +13,10 @@

<%= 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 %>

- \ No newline at end of file + diff --git a/core/lib/spree/core/testing_support/factories/product_factory.rb b/core/lib/spree/core/testing_support/factories/product_factory.rb index 837e35c0acc..51d8892dec9 100644 --- a/core/lib/spree/core/testing_support/factories/product_factory.rb +++ b/core/lib/spree/core/testing_support/factories/product_factory.rb @@ -1,14 +1,9 @@ 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' @@ -16,6 +11,11 @@ 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 diff --git a/core/spec/controllers/controller_helpers_spec.rb b/core/spec/controllers/controller_helpers_spec.rb index ca7e00d82a6..dc71f9cd7c1 100644 --- a/core/spec/controllers/controller_helpers_spec.rb +++ b/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 diff --git a/core/spec/controllers/spree/admin/base_controller_spec.rb b/core/spec/controllers/spree/admin/base_controller_spec.rb index 5e27fac4517..5c1757b1f48 100644 --- a/core/spec/controllers/spree/admin/base_controller_spec.rb +++ b/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 diff --git a/core/spec/controllers/spree/admin/image_settings_controller_spec.rb b/core/spec/controllers/spree/admin/image_settings_controller_spec.rb index 65234860681..ae739f07883 100644 --- a/core/spec/controllers/spree/admin/image_settings_controller_spec.rb +++ b/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 diff --git a/core/spec/controllers/spree/admin/mail_methods_controller_spec.rb b/core/spec/controllers/spree/admin/mail_methods_controller_spec.rb index e828b0b8e9a..eb5215bda24 100644 --- a/core/spec/controllers/spree/admin/mail_methods_controller_spec.rb +++ b/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 diff --git a/core/spec/controllers/spree/admin/orders_controller_spec.rb b/core/spec/controllers/spree/admin/orders_controller_spec.rb index 9e8fc94f12e..2847d2af5e0 100644 --- a/core/spec/controllers/spree/admin/orders_controller_spec.rb +++ b/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 diff --git a/core/spec/controllers/spree/admin/products_controller_spec.rb b/core/spec/controllers/spree/admin/products_controller_spec.rb index d11a1e27b69..18c648f5b3d 100644 --- a/core/spec/controllers/spree/admin/products_controller_spec.rb +++ b/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 diff --git a/core/spec/controllers/spree/admin/users_controller_spec.rb b/core/spec/controllers/spree/admin/users_controller_spec.rb index ea4ebed2041..d115c18a0d3 100644 --- a/core/spec/controllers/spree/admin/users_controller_spec.rb +++ b/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) diff --git a/core/spec/controllers/spree/checkout_controller_spec.rb b/core/spec/controllers/spree/checkout_controller_spec.rb index 5bd71c9bfc4..6124bd783c3 100644 --- a/core/spec/controllers/spree/checkout_controller_spec.rb +++ b/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 diff --git a/core/spec/controllers/spree/content_controller_spec.rb b/core/spec/controllers/spree/content_controller_spec.rb index b214ffa93d2..bf92a90f18f 100644 --- a/core/spec/controllers/spree/content_controller_spec.rb +++ b/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 diff --git a/core/spec/controllers/spree/orders_controller_extension_spec.rb b/core/spec/controllers/spree/orders_controller_extension_spec.rb index ca41c81fcd6..34f63c38415 100644 --- a/core/spec/controllers/spree/orders_controller_extension_spec.rb +++ b/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 diff --git a/core/spec/controllers/spree/orders_controller_spec.rb b/core/spec/controllers/spree/orders_controller_spec.rb index 6c4330e7b06..8b36c46d662 100644 --- a/core/spec/controllers/spree/orders_controller_spec.rb +++ b/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 diff --git a/core/spec/lib/search/base_spec.rb b/core/spec/lib/search/base_spec.rb index 14e05ab198a..049da69f7d0 100644 --- a/core/spec/lib/search/base_spec.rb +++ b/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) diff --git a/core/spec/models/payment_method_spec.rb b/core/spec/models/payment_method_spec.rb index 8826c3bd5b4..ba90d5a1d80 100644 --- a/core/spec/models/payment_method_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/configuration/analytics_tracker_spec.rb b/core/spec/requests/admin/configuration/analytics_tracker_spec.rb index 738e01470aa..777da7b1b8a 100644 --- a/core/spec/requests/admin/configuration/analytics_tracker_spec.rb +++ b/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" diff --git a/core/spec/requests/admin/configuration/general_settings_spec.rb b/core/spec/requests/admin/configuration/general_settings_spec.rb index 4661fac282b..f6ddba07254 100644 --- a/core/spec/requests/admin/configuration/general_settings_spec.rb +++ b/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" diff --git a/core/spec/requests/admin/configuration/inventory_settings_spec.rb b/core/spec/requests/admin/configuration/inventory_settings_spec.rb index eeb785548ff..2e0b9ccc4b6 100644 --- a/core/spec/requests/admin/configuration/inventory_settings_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/configuration/mail_methods_spec.rb b/core/spec/requests/admin/configuration/mail_methods_spec.rb index b3c5ac0378e..cb6566f1e74 100644 --- a/core/spec/requests/admin/configuration/mail_methods_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/configuration/payment_methods_spec.rb b/core/spec/requests/admin/configuration/payment_methods_spec.rb index b2d13595fca..d6c5b1b8829 100644 --- a/core/spec/requests/admin/configuration/payment_methods_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/configuration/shipping_methods_spec.rb b/core/spec/requests/admin/configuration/shipping_methods_spec.rb index d6b5d6a7f40..10d444e46d5 100644 --- a/core/spec/requests/admin/configuration/shipping_methods_spec.rb +++ b/core/spec/requests/admin/configuration/shipping_methods_spec.rb @@ -8,6 +8,8 @@ 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 @@ -15,7 +17,6 @@ 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 diff --git a/core/spec/requests/admin/configuration/states_spec.rb b/core/spec/requests/admin/configuration/states_spec.rb index 7f001304dbc..ace3e71d1cf 100644 --- a/core/spec/requests/admin/configuration/states_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/configuration/tax_categories_spec.rb b/core/spec/requests/admin/configuration/tax_categories_spec.rb index 2fecf0f0e30..4e67595867b 100644 --- a/core/spec/requests/admin/configuration/tax_categories_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/configuration/tax_rates_spec.rb b/core/spec/requests/admin/configuration/tax_rates_spec.rb index f1a4a670b08..5e077a4aa47 100644 --- a/core/spec/requests/admin/configuration/tax_rates_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/configuration/taxonomies_spec.rb b/core/spec/requests/admin/configuration/taxonomies_spec.rb index 3652c5b0ed1..0bf6b9dc62c 100644 --- a/core/spec/requests/admin/configuration/taxonomies_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/configuration/zones_spec.rb b/core/spec/requests/admin/configuration/zones_spec.rb index a1784054d06..dc8c2bf5baa 100644 --- a/core/spec/requests/admin/configuration/zones_spec.rb +++ b/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" diff --git a/core/spec/requests/admin/homepage_spec.rb b/core/spec/requests/admin/homepage_spec.rb index f131ab4f4fa..ee748cdc12f 100644 --- a/core/spec/requests/admin/homepage_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/orders/adjustments_spec.rb b/core/spec/requests/admin/orders/adjustments_spec.rb index a5f69017cdf..4f1d2acdb1e 100644 --- a/core/spec/requests/admin/orders/adjustments_spec.rb +++ b/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) diff --git a/core/spec/requests/admin/orders/customer_details_spec.rb b/core/spec/requests/admin/orders/customer_details_spec.rb index b0b7a548058..557ab2c8ab3 100644 --- a/core/spec/requests/admin/orders/customer_details_spec.rb +++ b/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" } diff --git a/core/spec/requests/admin/orders/history_spec.rb b/core/spec/requests/admin/orders/history_spec.rb index 98d41ea20f1..70892ecd56a 100644 --- a/core/spec/requests/admin/orders/history_spec.rb +++ b/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" } diff --git a/core/spec/requests/admin/orders/listing_spec.rb b/core/spec/requests/admin/orders/listing_spec.rb index 01acb85a603..1045280ee4b 100644 --- a/core/spec/requests/admin/orders/listing_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/orders/order_details_spec.rb b/core/spec/requests/admin/orders/order_details_spec.rb index 773c728874e..48cb0eff22a 100644 --- a/core/spec/requests/admin/orders/order_details_spec.rb +++ b/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! diff --git a/core/spec/requests/admin/orders/return_authorizations_spec.rb b/core/spec/requests/admin/orders/return_authorizations_spec.rb index 19bac0e8beb..be37aadaa68 100644 --- a/core/spec/requests/admin/orders/return_authorizations_spec.rb +++ b/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, diff --git a/core/spec/requests/admin/products/edit/images_spec.rb b/core/spec/requests/admin/products/edit/images_spec.rb index 9d01f4472ac..a226b818b12 100644 --- a/core/spec/requests/admin/products/edit/images_spec.rb +++ b/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" } diff --git a/core/spec/requests/admin/products/edit/products_spec.rb b/core/spec/requests/admin/products/edit/products_spec.rb index f9c74358978..72d58ca5649 100644 --- a/core/spec/requests/admin/products/edit/products_spec.rb +++ b/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' } diff --git a/core/spec/requests/admin/products/edit/taxons_spec.rb b/core/spec/requests/admin/products/edit/taxons_spec.rb index 5de09808a5a..530475f8774 100644 --- a/core/spec/requests/admin/products/edit/taxons_spec.rb +++ b/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" } diff --git a/core/spec/requests/admin/products/edit/variants_spec.rb b/core/spec/requests/admin/products/edit/variants_spec.rb index 19fa5efba2e..6da6d44b933 100644 --- a/core/spec/requests/admin/products/edit/variants_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/products/option_types_spec.rb b/core/spec/requests/admin/products/option_types_spec.rb index c2ee7167436..813e9022a64 100644 --- a/core/spec/requests/admin/products/option_types_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/products/products_spec.rb b/core/spec/requests/admin/products/products_spec.rb index 55c11de77fc..2e9c77079d5 100644 --- a/core/spec/requests/admin/products/products_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/products/properties_spec.rb b/core/spec/requests/admin/products/properties_spec.rb index f77cc29d4d3..df08ec356cb 100644 --- a/core/spec/requests/admin/products/properties_spec.rb +++ b/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 diff --git a/core/spec/requests/admin/products/prototypes_spec.rb b/core/spec/requests/admin/products/prototypes_spec.rb index 4a8e3cf8667..cc5272e5817 100644 --- a/core/spec/requests/admin/products/prototypes_spec.rb +++ b/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" diff --git a/core/spec/requests/admin/products/variant_spec.rb b/core/spec/requests/admin/products/variant_spec.rb index a1bb3ba5cf1..65aeadd4765 100644 --- a/core/spec/requests/admin/products/variant_spec.rb +++ b/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" } diff --git a/core/spec/requests/admin/reports_spec.rb b/core/spec/requests/admin/reports_spec.rb index ab426ab69d2..bd734fdee25 100644 --- a/core/spec/requests/admin/reports_spec.rb +++ b/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" diff --git a/core/spec/requests/admin/users_spec.rb b/core/spec/requests/admin/users_spec.rb index d5d42ffb45a..95815861ac8 100644 --- a/core/spec/requests/admin/users_spec.rb +++ b/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 diff --git a/core/spec/requests/order_spec.rb b/core/spec/requests/order_spec.rb new file mode 100644 index 00000000000..78c65ffbf0a --- /dev/null +++ b/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 diff --git a/core/spec/spec_helper.rb b/core/spec/spec_helper.rb index 552c9b1c541..69dd8a9bc82 100644 --- a/core/spec/spec_helper.rb +++ b/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 ]) diff --git a/core/spec/support/test_gateway.rb b/core/spec/support/test_gateway.rb new file mode 100644 index 00000000000..f6cf9ea0a00 --- /dev/null +++ b/core/spec/support/test_gateway.rb @@ -0,0 +1,2 @@ +class Spree::Gateway::Test < Spree::Gateway +end diff --git a/dash/Gemfile b/dash/Gemfile new file mode 100644 index 00000000000..af51fbf0c11 --- /dev/null +++ b/dash/Gemfile @@ -0,0 +1,5 @@ +eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb')) + +gem 'spree_core', :path => '../core' + +gemspec diff --git a/promo/Gemfile b/promo/Gemfile new file mode 100644 index 00000000000..7a36159d160 --- /dev/null +++ b/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