Skip to content

Commit 6dce9ba

Browse files
committed
Isolate each component of Spree
This commit contains a whole bunch of changes, from pull request spree#1296 which will fix spree#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.
1 parent a980448 commit 6dce9ba

File tree

65 files changed

+164
-173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+164
-173
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ db/*.sqlite3*
2323
db/schema.rb
2424
doc/**/*
2525
Gemfile.lock
26-
*/Gemfile
2726
*/Gemfile.lock
2827
lib/products_index_profiler.rb
2928
log/*.log

.travis.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ env:
55
- DB=sqlite
66
- DB=mysql
77
- DB=postgres
8-
script: "DISPLAY=:99.0 bundle exec rake"
8+
script:
9+
- "export DISPLAY=:99.0"
10+
- "alias set_gemfile='export BUNDLE_GEMFILE=\"`pwd`/Gemfile\"'"
11+
- "cd api; set_gemfile; bundle install --quiet; bundle exec rspec spec"
12+
- "cd ../auth; set_gemfile; bundle install --quiet; bundle exec rspec spec"
13+
- "cd ../core; set_gemfile; bundle install --quiet; bundle exec rspec spec"
14+
- "cd ../dash; set_gemfile; bundle install --quiet; bundle exec rspec spec"
15+
- "cd ../promo; set_gemfile; bundle install --quiet; bundle exec rspec spec"
16+
917
notifications:
1018
email:
1119
@@ -14,6 +22,7 @@ branches:
1422
only:
1523
- 1-0-stable
1624
- master
25+
- isolation
1726
rvm:
1827
- 1.8.7
1928
- 1.9.3

Gemfile

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,3 @@
1-
source 'http://rubygems.org'
2-
3-
gem 'json'
4-
gem 'sqlite3'
5-
gem 'mysql2'
6-
gem 'pg'
7-
8-
# Gems used only for assets and not required
9-
# in production environments by default.
10-
group :assets do
11-
gem 'sass-rails', "~> 3.2"
12-
gem 'coffee-rails', "~> 3.2"
13-
end
14-
15-
group :test do
16-
gem 'guard'
17-
gem 'guard-rspec', '~> 0.5.0'
18-
gem 'rspec-rails', '~> 2.8.0'
19-
gem 'factory_girl_rails', '~> 1.7.0'
20-
gem 'email_spec', '~> 1.2.1'
21-
22-
platform :ruby_18 do
23-
gem 'rcov'
24-
end
25-
26-
platform :ruby_19 do
27-
gem 'simplecov'
28-
end
29-
30-
gem 'ffaker'
31-
gem 'shoulda-matchers', '~> 1.0.0'
32-
gem 'capybara'
33-
gem 'selenium-webdriver', '2.16.0'
34-
gem 'database_cleaner', '0.7.1'
35-
gem 'launchy'
36-
end
37-
38-
# platform :ruby_18 do
39-
# gem "ruby-debug"
40-
# end
41-
42-
# platform :ruby_19 do
43-
# gem "ruby-debug19"
44-
# end
1+
eval(File.read(File.dirname(__FILE__) + '/common_spree_dependencies.rb'))
452

463
gemspec
47-
48-

Rakefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ end
2020

2121
task :default => :all_tests
2222

23-
desc "Run all tests for sqlite3 only"
24-
task :all_tests do
25-
%w(api auth core dash promo).each do |gem_name|
26-
puts "########################### #{gem_name} (spec) ###########################"
27-
sh "cd #{gem_name} && #{$0} spec"
28-
end
29-
end
30-
3123
desc "Run all tests for all supported databases"
3224
task :ci do
3325
cmd = "bundle update"; puts cmd; system cmd;

api/Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb'))
2+
3+
gem 'spree_core', :path => '../core'
4+
gem 'spree_auth', :path => '../auth'
5+
6+
gemspec

auth/Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb'))
2+
3+
gem 'spree_core', :path => '../core'
4+
5+
gemspec
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
require File.expand_path('../../base_controller_decorator', __FILE__)
22
Spree::Admin::UsersController.class_eval do
33
rescue_from Spree::User::DestroyWithOrdersError, :with => :user_destroy_with_orders_error
4+
5+
update.after :sign_in_if_change_own_password
6+
7+
before_filter :load_roles, :only => [:edit, :new, :update, :create]
8+
9+
private
10+
11+
def sign_in_if_change_own_password
12+
if current_user == @user && @user.password.present?
13+
sign_in(@user, :event => :authentication, :bypass => true)
14+
end
15+
end
16+
17+
def load_roles
18+
@roles = Spree::Role.scoped
19+
end
420
end
521

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Deface::Override.new(:virtual_path => "spree/admin/payment_methods/index",
2+
:name => "gateway_banner",
3+
:insert_after => "#listing_payment_methods",
4+
:partial => "spree/admin/banners/gateway")
5+
6+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require 'spec_helper'
2+
3+
describe 'Users' do
4+
before do
5+
user = Factory(:admin_user, :email => "[email protected]")
6+
sign_in_as!(user)
7+
visit spree.admin_users_path
8+
end
9+
10+
context "editing own user" do
11+
it "should let me edit own password" do
12+
click_link("[email protected]")
13+
click_link("Edit")
14+
fill_in "user_password", :with => "welcome"
15+
fill_in "user_password_confirmation", :with => "welcome"
16+
click_button "Update"
17+
18+
page.should have_content("successfully updated!")
19+
end
20+
end
21+
end

0 commit comments

Comments
 (0)