diff --git a/Gemfile b/Gemfile
index a7151ac..33a00a9 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,13 +1,6 @@
source 'https://rubygems.org'
-gem 'spree', '~> 1.2.0'
-gem 'spree_auth_devise', '~> 1.2.0'
-
-# 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
+gem 'spree', github: 'spree/spree', branch: '2-0-stable'
+gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-0-stable'
gemspec
diff --git a/Rakefile b/Rakefile
index a058444..ff86047 100644
--- a/Rakefile
+++ b/Rakefile
@@ -3,7 +3,7 @@ require 'rake/testtask'
require 'rake/packagetask'
require 'rubygems/package_task'
require 'rspec/core/rake_task'
-require 'spree/core/testing_support/common_rake'
+require 'spree/testing_support/common_rake'
RSpec::Core::RakeTask.new
diff --git a/Versionfile b/Versionfile
index 440a523..18eef21 100644
--- a/Versionfile
+++ b/Versionfile
@@ -1,4 +1,5 @@
-# "1.2.x" => { :branch => "master"}
+"2.0.x" => { :branch => "master"}
+"1.2.x" => { :ref => "a459bf2098c40855c35ffd786fc12fc2983bf7aa" }
"1.1.x" => { :branch => "spree-1-1-stable"}
"1.0.x" => { :branch => "spree-1-0-stable"}
"0.70.x" => { :branch => "spree-0-70-stable"}
diff --git a/app/assets/javascripts/store/spree_reuse_credit_card.js b/app/assets/javascripts/store/spree_reuse_credit_card.js
index 58888cd..50e57d2 100644
--- a/app/assets/javascripts/store/spree_reuse_credit_card.js
+++ b/app/assets/javascripts/store/spree_reuse_credit_card.js
@@ -47,7 +47,7 @@ $(document).on('click', '#use_existing_card_no', function () {
$("[data-hook=card_number]").show();
$("[data-hook=card_expiration]").show();
- $("[data-hook=cart_code]").show(); // unfortunately this is a typo in spree (cart v card)
+ $("[data-hook=card_code]").show();
restoreContinueButton();
@@ -97,7 +97,7 @@ function useExistingCardsInit() {
$("[data-hook=card_number]").hide();
$("[data-hook=card_expiration]").hide();
- $("[data-hook=cart_code]").hide(); // unfortunately this is a typo in spree (cart v card)
+ $("[data-hook=card_code]").hide();
disableContinueButton();
}
diff --git a/app/views/spree/checkout/payment/_existing_cards.html.erb b/app/views/spree/checkout/payment/_existing_cards.html.erb
index 843c503..56081d2 100644
--- a/app/views/spree/checkout/payment/_existing_cards.html.erb
+++ b/app/views/spree/checkout/payment/_existing_cards.html.erb
@@ -1,7 +1,7 @@
<%= content_for :head do %>
<%= javascript_tag do -%>
<%== "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
- var original_button_text = "<%= t(:save_and_continue) %>";
+ var original_button_text = "<%= Spree.t(:save_and_continue) %>";
<% end -%>
<% end %>
@@ -50,7 +50,7 @@
<%= card.year %> |
<%= radio_button_tag "existing_card", card.id, (@cards.size ==1) %> | <%# if we only have 1 saved card, autoselect %>
- <%= link_to (image_tag("admin/icons/delete.png") + t(:delete)),
+ <%= link_to Spree.t(:delete),
spree.credit_card_url(card),
:remote => true, :method => :delete,
:confirm => 'Are you sure?' %>
diff --git a/app/views/spree/users/_card_admin.html.erb b/app/views/spree/users/_card_admin.html.erb
index 1a4c7d1..453d4a8 100644
--- a/app/views/spree/users/_card_admin.html.erb
+++ b/app/views/spree/users/_card_admin.html.erb
@@ -8,7 +8,7 @@
- Credit Cards on File
+ Credit Cards on File
diff --git a/lib/generators/spree_reuse_credit_card/install/install_generator.rb b/lib/generators/spree_reuse_credit_card/install/install_generator.rb
index 6ceb42a..5e4b3bf 100644
--- a/lib/generators/spree_reuse_credit_card/install/install_generator.rb
+++ b/lib/generators/spree_reuse_credit_card/install/install_generator.rb
@@ -1,6 +1,7 @@
module SpreeReuseCreditCard
module Generators
class InstallGenerator < Rails::Generators::Base
+ class_option :auto_run_migrations, :type => :boolean, :default => false
def add_javascripts
append_file "app/assets/javascripts/store/all.js", "//= require store/spree_reuse_credit_card\n"
@@ -17,12 +18,12 @@ def add_migrations
end
def run_migrations
- res = ask "Would you like to run the migrations now? [Y/n]"
- if res == "" || res.downcase == "y"
- run 'bundle exec rake db:migrate'
- else
- puts "Skipping rake db:migrate, don't forget to run it!"
- end
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
+ if run_migrations
+ run 'bundle exec rake db:migrate'
+ else
+ puts 'Skipping rake db:migrate, don\'t forget to run it!'
+ end
end
end
end
diff --git a/spec/factories/order_factory.rb b/spec/factories/order_factory.rb
index fbaca02..7a6baa9 100644
--- a/spec/factories/order_factory.rb
+++ b/spec/factories/order_factory.rb
@@ -1,45 +1,22 @@
FactoryGirl.define do
factory :order_in_address_state, :parent => :order do
- after_build { |order|
- order.line_items << Factory(:line_item, :order => order)
+ after(:build) { |order|
+ order.line_items << FactoryGirl.create(:line_item)
}
- after_create { |order|
+ after(:create) { |order|
order.next!
}
end
factory :order_in_delivery_state, :parent => :order_in_address_state do
- after_create { |order| order.next! }
- end
-
- factory :order_in_payment_state, :parent => :order_in_delivery_state do
- after_create { |order|
- order.next!
- }
- end
-
- factory :order_in_confirm_state, :parent => :order_in_payment_state do
- after_create do |order|
+ after(:create) { |order|
+ create(:state, :country => create(:country))
+ create(:shipping_method)
+ create(:stock_location)
order.next!
- end
- end
-
- factory :order_in_complete_state, :parent => :order_in_confirm_state do
- after_create { |order| order.next! && order.finalize! }
+ }
end
-
-
-# factory :order_in_payment_state, :parent => :order do
-# after_create { |order|
-# # order.line_items << Factory(:line_item, :order => order)
-#
-# order.next!
-# order.next!
-# order.next!
-#
-# }
-# end
end
diff --git a/spec/features/pay_with_credit_cards_spec.rb b/spec/features/pay_with_credit_cards_spec.rb
index 228e5d6..708591f 100644
--- a/spec/features/pay_with_credit_cards_spec.rb
+++ b/spec/features/pay_with_credit_cards_spec.rb
@@ -1,16 +1,19 @@
require 'spec_helper'
-describe "PayWithCreditCards" do
+describe "PayWithCreditCards", :js => true do
+
describe "GET /checkout/payment" do
- let (:user) { Factory(:user) }
-
- before(:each) do
- @bogus_payment_method = Factory(:bogus_payment_method, :display_on => :front_end)
- Factory(:payment_method, :display_on => :front_end)
+ let!(:country) { create(:country) }
+ let!(:state) { create(:state, :country => country) }
+ let!(:shipping_method) { create(:shipping_method) }
+ let!(:stock_location) { create(:stock_location) }
+ let!(:mug) { create(:product, :name => "RoR Mug") }
+ let (:user) { create(:user) }
- shipping_method = Factory(:shipping_method)
- Spree::ShippingMethod.stub(:all_available) { [shipping_method] }
+ before(:each) do
+ @bogus_payment_method = create(:bogus_payment_method, :display_on => :front_end)
+ create(:payment_method, :display_on => :front_end)
sign_in_as!(user)
end
@@ -19,10 +22,6 @@
subject { page }
before do
- Factory(:product)
- Factory(:country)
- Factory(:state)
-
Spree::CreditCard.all.map(&:destroy)
visit spree.products_path
@@ -79,31 +78,57 @@
context "existing cards" do
before(:each) do
- # set up existing payments with this credit card
- @credit_card = Factory(:credit_card, :gateway_payment_profile_id => 'FAKE_GATEWAY_ID')
+ # # set up existing payments with this credit card
+ # @credit_card = create(:credit_card, :gateway_payment_profile_id => 'FAKE_GATEWAY_ID')
+ #
+ # order = create(:order_in_delivery_state, :user => user)
+ # order.update! # set order.total
+ #
+ # # go to payment state
+ # order.next
+ # order.state.should eq('payment')
+ #
+ # # add a payment
+ # payment = create(:payment, :order => order, :source => @credit_card, :amount => order.total, :payment_method => @bogus_payment_method)
+ #
+ # # go to confirm
+ # order.next
+ # order.state.should eq('confirm')
+ #
+ # # go to complete
+ # order.next
+ # order.state.should eq('complete')
+ #
+ # # capture payment
+ # order.payment.capture!
+ # order.update!
+ # order.should_not be_outstanding_balance
- order = Factory(:order_in_delivery_state, :user => user)
- order.update! # set order.total
+ visit spree.products_path
- # go to payment state
- order.next
- order.state.should eq('payment')
+ find(:xpath, "//div[@class='product-image']/a").click
+ click_button 'Add To Cart'
+ click_button 'Checkout'
+ fill_in 'order_bill_address_attributes_firstname', :with => 'Jeff'
+ fill_in 'order_bill_address_attributes_lastname', :with => 'Squires'
+ fill_in 'order_bill_address_attributes_address1', :with => '123 Foo St'
+ fill_in 'order_bill_address_attributes_city', :with => 'Fooville'
+ select 'Alabama', :from => 'order_bill_address_attributes_state_id'
+ fill_in 'order_bill_address_attributes_zipcode', :with => '12345'
+ fill_in 'order_bill_address_attributes_phone', :with => '123-123-1234'
+ check "Use Billing Address"
- # add a payment
- payment = Factory(:payment, :order => order, :source => @credit_card, :amount => order.total, :payment_method => @bogus_payment_method)
+ click_button 'Save and Continue'
+ click_button "Save and Continue"
- # go to confirm
- order.next
- order.state.should eq('confirm')
+ fill_in "Card Number", :with => '4111111111111111'
+ fill_in "Card Code", :with => '111'
- # go to complete
- order.next
- order.state.should eq('complete')
+ click_button "Save and Continue"
+ click_button "Place Order"
+ page.should have_content('Your order has been processed successfully')
- # capture payment
- order.payment.capture!
- order.update!
- order.should_not be_outstanding_balance
+ @credit_card = Spree::Payment.last.source
end
it "allows an existing credit card to be chosen from list and used for a purchase" do
@@ -116,8 +141,7 @@
fill_in 'order_bill_address_attributes_lastname', :with => 'Squires'
fill_in 'order_bill_address_attributes_address1', :with => '123 Foo St'
fill_in 'order_bill_address_attributes_city', :with => 'Fooville'
- fill_in 'order_bill_address_attributes_state_name',:with => 'Alabama'
-
+ select 'Alabama', :from => 'order_bill_address_attributes_state_id'
fill_in 'order_bill_address_attributes_zipcode', :with => '12345'
fill_in 'order_bill_address_attributes_phone', :with => '123-123-1234'
check "Use Billing Address"
@@ -126,7 +150,8 @@
click_button 'Save and Continue'
- page.should have_xpath("//table[@class='existing-credit-card-list']/tbody/tr", :text => @credit_card.last_digits) #, :count => x)
+ sleep 10
+ page.should have_xpath("//table[@class='existing-credit-card-list']/tbody/tr", :text => @credit_card.last_digits)
choose 'existing_card'
click_button 'Save and Continue'
@@ -134,7 +159,7 @@
page.should have_content "Ending in #{@credit_card.last_digits}"
end
- it 'allows selecting a different payment method', :js => true do
+ it 'allows selecting a different payment method' do
visit spree.products_path
find(:xpath, "//div[@class='product-image']/a").click
diff --git a/spec/lib/card_reuse_spec.rb b/spec/lib/card_reuse_spec.rb
index 1f9cfd9..ce72422 100644
--- a/spec/lib/card_reuse_spec.rb
+++ b/spec/lib/card_reuse_spec.rb
@@ -12,35 +12,35 @@
end
context 'with a valid user' do
- let(:user) { mock(:user) }
+ let(:user) { double(:user) }
context 'with payments' do
let(:reuseable_source) {
- mock(:reuseable_source).tap do |source|
+ double(:reuseable_source).tap do |source|
fixture.stub(:valid_for_reuse?).with(source).and_return(true)
end
}
let(:non_reuseable_source) {
- mock(:non_reuseable_source).tap do |source|
+ double(:non_reuseable_source).tap do |source|
fixture.stub(:valid_for_reuse?).with(source).and_return(false)
end
}
let(:first_reusable_payment) {
- mock(:first_reusable_payment).tap do |payment|
+ double(:first_reusable_payment).tap do |payment|
payment.stub(:source).and_return(reuseable_source)
end
}
let(:second_reusable_payment) {
- mock(:second_reusable_payment).tap do |payment|
+ double(:second_reusable_payment).tap do |payment|
payment.stub(:source).and_return(reuseable_source)
end
}
let(:non_reusable_payment) {
- mock(:non_reusable_payment).tap do |payment|
+ double(:non_reusable_payment).tap do |payment|
payment.stub(:source).and_return(non_reuseable_source)
end
}
@@ -74,7 +74,7 @@
describe '#valid_for_resuse' do
let(:source) {
- mock(:source).tap do |s|
+ double(:source).tap do |s|
s.stub(:gateway_payment_profile_id).and_return('gateway_payment_profile_id')
s.stub(:gateway_customer_profile_id).and_return('gateway_customer_profile_id')
s.stub(:deleted?).and_return(false)
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 98c00db..e869640 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -3,7 +3,6 @@
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require 'rspec/rails'
require 'database_cleaner'
-require 'spree/core/url_helpers'
require 'ffaker'
require 'factory_girl'
@@ -18,9 +17,9 @@
# in spec/support/ and its subdirectories.
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f }
-require 'spree/core/testing_support/fixtures'
-require 'spree/core/testing_support/factories'
-require 'spree/core/testing_support/controller_requests'
+require 'spree/testing_support/factories'
+require 'spree/testing_support/controller_requests'
+require 'spree/testing_support/url_helpers'
RSpec.configure do |config|
# ## Mock Framework
@@ -41,8 +40,8 @@
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::TestingSupport::UrlHelpers
+ config.include Spree::TestingSupport::ControllerRequests, :type => :controller
config.include Devise::TestHelpers, :type => :controller
config.include Rack::Test::Methods, :type => :requests
end
diff --git a/spree_reuse_credit_card.gemspec b/spree_reuse_credit_card.gemspec
index 22ba239..62b389f 100644
--- a/spree_reuse_credit_card.gemspec
+++ b/spree_reuse_credit_card.gemspec
@@ -17,11 +17,11 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'
- s.add_dependency 'spree', '~> 1.2.0'
+ s.add_dependency 'spree', '~> 2.0.0'
- s.add_development_dependency 'spree_auth_devise', '~> 1.2.0'
+ s.add_development_dependency 'spree_auth_devise'
s.add_development_dependency 'capybara', '~> 1.1'
- s.add_development_dependency 'factory_girl_rails', '1.5.0'
+ s.add_development_dependency 'factory_girl_rails', '~> 4.2.0'
s.add_development_dependency 'ffaker'
s.add_development_dependency 'rspec-rails', '~> 2.7'
s.add_development_dependency 'sqlite3'
|