solidus_core 2.0.0.rc1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/models/spree/credit_card.rb +4 -6
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/deprecation.rb +1 -1
- data/spec/models/spree/adjustment_spec.rb +2 -1
- data/spec/models/spree/credit_card_spec.rb +12 -12
- data/spec/models/spree/order_shipping_spec.rb +2 -2
- data/spec/models/spree/product_spec.rb +20 -11
- data/spec/models/spree/stock_item_spec.rb +32 -19
- data/spec/models/spree/store_credit_spec.rb +2 -2
- metadata +4 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 0a431556798d4e71cf6ddd2705c1e9771a945218
         | 
| 4 | 
            +
              data.tar.gz: a573024f06b38e92edb6e2ae89d3893a2259d690
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 81ca409e7263d31ea26aa9aac0c5952bd71d261da44dc0af933bd3257865323f00e528548e1ec9a4957c5fb47aadfd80f498b80a9ca37fdd32810c8cd3d6c9fb
         | 
| 7 | 
            +
              data.tar.gz: 9ebb33484c741e1cd4631d05d0ed5569ab0c340e9672cb8b66d028379ff7a75eb0f4916b67c9ae3f68e6aa52cd1a318b6c2e80fa80c0531d426b18b6c0a2385f
         | 
| @@ -64,11 +64,10 @@ module Spree | |
| 64 64 | 
             
                #
         | 
| 65 65 | 
             
                # @param num [String] the desired credit card number
         | 
| 66 66 | 
             
                def number=(num)
         | 
| 67 | 
            -
                  @number = | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
                            end
         | 
| 67 | 
            +
                  @number =
         | 
| 68 | 
            +
                    if num.is_a?(String)
         | 
| 69 | 
            +
                      num.gsub(/[^0-9]/, '')
         | 
| 70 | 
            +
                    end
         | 
| 72 71 | 
             
                end
         | 
| 73 72 |  | 
| 74 73 | 
             
                # Sets the credit card type, converting it to the preferred internal
         | 
| @@ -89,7 +88,6 @@ module Spree | |
| 89 88 |  | 
| 90 89 | 
             
                # Sets the last digits field based on the assigned credit card number.
         | 
| 91 90 | 
             
                def set_last_digits
         | 
| 92 | 
            -
                  number.to_s.gsub!(/\s/, '')
         | 
| 93 91 | 
             
                  verification_value.to_s.gsub!(/\s/, '')
         | 
| 94 92 | 
             
                  self.last_digits ||= number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)
         | 
| 95 93 | 
             
                end
         | 
    
        data/lib/spree/core/version.rb
    CHANGED
    
    
    
        data/lib/spree/deprecation.rb
    CHANGED
    
    
| @@ -14,7 +14,8 @@ describe Spree::Adjustment, type: :model do | |
| 14 14 | 
             
                let(:adjustment) { Spree::Adjustment.create(label: "Adjustment", amount: 5, order: order, adjustable: line_item) }
         | 
| 15 15 |  | 
| 16 16 | 
             
                it 'touches the adjustable' do
         | 
| 17 | 
            -
                   | 
| 17 | 
            +
                  line_item.update_columns(updated_at: 1.day.ago)
         | 
| 18 | 
            +
                  expect { adjustment.save! }.to change { line_item.updated_at }
         | 
| 18 19 | 
             
                end
         | 
| 19 20 | 
             
              end
         | 
| 20 21 |  | 
| @@ -35,7 +35,7 @@ describe Spree::CreditCard, type: :model do | |
| 35 35 | 
             
                allow(@payment).to receive_messages payment_method: @payment_gateway
         | 
| 36 36 | 
             
              end
         | 
| 37 37 |  | 
| 38 | 
            -
               | 
| 38 | 
            +
              describe "#can_capture?" do
         | 
| 39 39 | 
             
                it "should be true if payment is pending" do
         | 
| 40 40 | 
             
                  payment = mock_model(Spree::Payment, pending?: true, created_at: Time.current)
         | 
| 41 41 | 
             
                  expect(credit_card.can_capture?(payment)).to be true
         | 
| @@ -47,14 +47,14 @@ describe Spree::CreditCard, type: :model do | |
| 47 47 | 
             
                end
         | 
| 48 48 | 
             
              end
         | 
| 49 49 |  | 
| 50 | 
            -
               | 
| 50 | 
            +
              describe "#can_void?" do
         | 
| 51 51 | 
             
                it "should be true if payment is not void" do
         | 
| 52 52 | 
             
                  payment = mock_model(Spree::Payment, failed?: false, void?: false)
         | 
| 53 53 | 
             
                  expect(credit_card.can_void?(payment)).to be true
         | 
| 54 54 | 
             
                end
         | 
| 55 55 | 
             
              end
         | 
| 56 56 |  | 
| 57 | 
            -
               | 
| 57 | 
            +
              describe "#can_credit?" do
         | 
| 58 58 | 
             
                it "should be false if payment is not completed" do
         | 
| 59 59 | 
             
                  payment = mock_model(Spree::Payment, completed?: false)
         | 
| 60 60 | 
             
                  expect(credit_card.can_credit?(payment)).to be false
         | 
| @@ -66,7 +66,7 @@ describe Spree::CreditCard, type: :model do | |
| 66 66 | 
             
                end
         | 
| 67 67 | 
             
              end
         | 
| 68 68 |  | 
| 69 | 
            -
               | 
| 69 | 
            +
              describe "#valid?" do
         | 
| 70 70 | 
             
                it "should validate presence of number" do
         | 
| 71 71 | 
             
                  credit_card.attributes = valid_credit_card_attributes.except(:number)
         | 
| 72 72 | 
             
                  expect(credit_card).not_to be_valid
         | 
| @@ -109,7 +109,7 @@ describe Spree::CreditCard, type: :model do | |
| 109 109 | 
             
                end
         | 
| 110 110 | 
             
              end
         | 
| 111 111 |  | 
| 112 | 
            -
               | 
| 112 | 
            +
              describe "#save" do
         | 
| 113 113 | 
             
                before do
         | 
| 114 114 | 
             
                  credit_card.attributes = valid_credit_card_attributes
         | 
| 115 115 | 
             
                  credit_card.save!
         | 
| @@ -145,7 +145,7 @@ describe Spree::CreditCard, type: :model do | |
| 145 145 | 
             
                end
         | 
| 146 146 | 
             
              end
         | 
| 147 147 |  | 
| 148 | 
            -
               | 
| 148 | 
            +
              describe "#number=" do
         | 
| 149 149 | 
             
                it "should strip non-numeric characters from card input" do
         | 
| 150 150 | 
             
                  credit_card.number = "6011000990139424"
         | 
| 151 151 | 
             
                  expect(credit_card.number).to eq("6011000990139424")
         | 
| @@ -161,7 +161,7 @@ describe Spree::CreditCard, type: :model do | |
| 161 161 | 
             
              end
         | 
| 162 162 |  | 
| 163 163 | 
             
              # Regression test for https://github.com/spree/spree/issues/3847 and https://github.com/spree/spree/issues/3896
         | 
| 164 | 
            -
               | 
| 164 | 
            +
              describe "#expiry=" do
         | 
| 165 165 | 
             
                it "can set with a 2-digit month and year" do
         | 
| 166 166 | 
             
                  credit_card.expiry = '04 / 15'
         | 
| 167 167 | 
             
                  expect(credit_card.month).to eq('4')
         | 
| @@ -208,7 +208,7 @@ describe Spree::CreditCard, type: :model do | |
| 208 208 | 
             
                end
         | 
| 209 209 | 
             
              end
         | 
| 210 210 |  | 
| 211 | 
            -
               | 
| 211 | 
            +
              describe "#cc_type=" do
         | 
| 212 212 | 
             
                it "converts between the different types" do
         | 
| 213 213 | 
             
                  credit_card.cc_type = 'mastercard'
         | 
| 214 214 | 
             
                  expect(credit_card.cc_type).to eq('master')
         | 
| @@ -257,13 +257,13 @@ describe Spree::CreditCard, type: :model do | |
| 257 257 | 
             
                end
         | 
| 258 258 | 
             
              end
         | 
| 259 259 |  | 
| 260 | 
            -
               | 
| 260 | 
            +
              describe "#associations" do
         | 
| 261 261 | 
             
                it "should be able to access its payments" do
         | 
| 262 262 | 
             
                  credit_card.payments.to_a
         | 
| 263 263 | 
             
                end
         | 
| 264 264 | 
             
              end
         | 
| 265 265 |  | 
| 266 | 
            -
               | 
| 266 | 
            +
              describe "#first_name" do
         | 
| 267 267 | 
             
                before do
         | 
| 268 268 | 
             
                  credit_card.name = "Ludwig van Beethoven"
         | 
| 269 269 | 
             
                end
         | 
| @@ -273,7 +273,7 @@ describe Spree::CreditCard, type: :model do | |
| 273 273 | 
             
                end
         | 
| 274 274 | 
             
              end
         | 
| 275 275 |  | 
| 276 | 
            -
               | 
| 276 | 
            +
              describe "#last_name" do
         | 
| 277 277 | 
             
                before do
         | 
| 278 278 | 
             
                  credit_card.name = "Ludwig van Beethoven"
         | 
| 279 279 | 
             
                end
         | 
| @@ -283,7 +283,7 @@ describe Spree::CreditCard, type: :model do | |
| 283 283 | 
             
                end
         | 
| 284 284 | 
             
              end
         | 
| 285 285 |  | 
| 286 | 
            -
               | 
| 286 | 
            +
              describe "#to_active_merchant" do
         | 
| 287 287 | 
             
                before do
         | 
| 288 288 | 
             
                  credit_card.number = "4111111111111111"
         | 
| 289 289 | 
             
                  credit_card.year = Time.current.year
         | 
| @@ -30,7 +30,7 @@ describe Spree::OrderShipping do | |
| 30 30 |  | 
| 31 31 | 
             
                it "updates shipment.shipped_at" do
         | 
| 32 32 | 
             
                  Timecop.freeze do |now|
         | 
| 33 | 
            -
                    expect { subject }.to change { shipment.shipped_at }.from(nil).to(now)
         | 
| 33 | 
            +
                    expect { subject }.to change { shipment.shipped_at }.from(nil).to be_within(1.second).of(now)
         | 
| 34 34 | 
             
                  end
         | 
| 35 35 | 
             
                end
         | 
| 36 36 |  | 
| @@ -40,7 +40,7 @@ describe Spree::OrderShipping do | |
| 40 40 | 
             
                    Timecop.freeze(future) do
         | 
| 41 41 | 
             
                      subject
         | 
| 42 42 | 
             
                    end
         | 
| 43 | 
            -
                  end.to change { order.updated_at }. | 
| 43 | 
            +
                  end.to change { order.updated_at }.to be_within(1.second).of(future)
         | 
| 44 44 | 
             
                end
         | 
| 45 45 | 
             
              end
         | 
| 46 46 |  | 
| @@ -97,6 +97,7 @@ describe Spree::Product, type: :model do | |
| 97 97 | 
             
                      master = product.master
         | 
| 98 98 | 
             
                      master.default_price.price = 11
         | 
| 99 99 | 
             
                      master.save!
         | 
| 100 | 
            +
                      product.update_columns(updated_at: 1.day.ago)
         | 
| 100 101 | 
             
                      product.master.default_price.price = 12
         | 
| 101 102 | 
             
                    end
         | 
| 102 103 |  | 
| @@ -342,19 +343,27 @@ describe Spree::Product, type: :model do | |
| 342 343 |  | 
| 343 344 | 
             
                context "associations" do
         | 
| 344 345 | 
             
                  describe "product_option_types" do
         | 
| 345 | 
            -
                     | 
| 346 | 
            -
                       | 
| 347 | 
            -
             | 
| 348 | 
            -
             | 
| 349 | 
            -
             | 
| 346 | 
            +
                    context "with no existing option types" do
         | 
| 347 | 
            +
                      before { product.update_columns(updated_at: 1.day.ago) }
         | 
| 348 | 
            +
             | 
| 349 | 
            +
                      it "touches the product instance when an option type is added" do
         | 
| 350 | 
            +
                        expect {
         | 
| 351 | 
            +
                          product.product_option_types.create(option_type: create(:option_type, name: 'new-option-type'))
         | 
| 352 | 
            +
                        }.to change { product.reload.updated_at }
         | 
| 353 | 
            +
                      end
         | 
| 350 354 | 
             
                    end
         | 
| 351 355 |  | 
| 352 | 
            -
                     | 
| 353 | 
            -
                       | 
| 354 | 
            -
             | 
| 355 | 
            -
                        product. | 
| 356 | 
            -
             | 
| 357 | 
            -
             | 
| 356 | 
            +
                    context "with an existing option type" do
         | 
| 357 | 
            +
                      before do
         | 
| 358 | 
            +
                        product.product_option_types.create(option_type: create(:option_type, name: 'new-option-type'))
         | 
| 359 | 
            +
                        product.update_columns(updated_at: 1.day.ago)
         | 
| 360 | 
            +
                      end
         | 
| 361 | 
            +
             | 
| 362 | 
            +
                      it "touches product instance when an option type is removed" do
         | 
| 363 | 
            +
                        expect {
         | 
| 364 | 
            +
                          product.product_option_types = []
         | 
| 365 | 
            +
                        }.to change { product.reload.updated_at }
         | 
| 366 | 
            +
                      end
         | 
| 358 367 | 
             
                    end
         | 
| 359 368 | 
             
                  end
         | 
| 360 369 | 
             
                end
         | 
| @@ -199,30 +199,41 @@ describe Spree::StockItem, type: :model do | |
| 199 199 |  | 
| 200 200 | 
             
                  let(:inventory_cache_threshold) { 5 }
         | 
| 201 201 |  | 
| 202 | 
            -
                   | 
| 203 | 
            -
                     | 
| 204 | 
            -
             | 
| 205 | 
            -
                    end.to change { subject.variant.updated_at }
         | 
| 202 | 
            +
                  before do
         | 
| 203 | 
            +
                    subject.set_count_on_hand(existing_count_on_hand)
         | 
| 204 | 
            +
                    subject.variant.update_column(:updated_at, 1.day.ago)
         | 
| 206 205 | 
             
                  end
         | 
| 207 206 |  | 
| 208 | 
            -
                   | 
| 209 | 
            -
                     | 
| 210 | 
            -
                    expect do
         | 
| 211 | 
            -
                      subject.set_count_on_hand(7)
         | 
| 212 | 
            -
                    end.to change { subject.variant.updated_at }
         | 
| 213 | 
            -
                  end
         | 
| 207 | 
            +
                  context "beginning above threshold" do
         | 
| 208 | 
            +
                    let(:existing_count_on_hand) { 10 }
         | 
| 214 209 |  | 
| 215 | 
            -
             | 
| 216 | 
            -
             | 
| 217 | 
            -
             | 
| 218 | 
            -
                      subject. | 
| 219 | 
            -
                    end | 
| 210 | 
            +
                    it "count on hand falls below threshold" do
         | 
| 211 | 
            +
                      expect do
         | 
| 212 | 
            +
                        subject.set_count_on_hand(3)
         | 
| 213 | 
            +
                      end.to change { subject.variant.updated_at }
         | 
| 214 | 
            +
                    end
         | 
| 215 | 
            +
             | 
| 216 | 
            +
                    it "count on hand stays above threshold" do
         | 
| 217 | 
            +
                      expect do
         | 
| 218 | 
            +
                        subject.set_count_on_hand(8)
         | 
| 219 | 
            +
                      end.not_to change { subject.variant.updated_at }
         | 
| 220 | 
            +
                    end
         | 
| 220 221 | 
             
                  end
         | 
| 221 222 |  | 
| 222 | 
            -
                   | 
| 223 | 
            -
                     | 
| 224 | 
            -
             | 
| 225 | 
            -
                     | 
| 223 | 
            +
                  context "beginning below threshold" do
         | 
| 224 | 
            +
                    let(:existing_count_on_hand) { 2 }
         | 
| 225 | 
            +
             | 
| 226 | 
            +
                    it "count on hand rises above threshold" do
         | 
| 227 | 
            +
                      expect do
         | 
| 228 | 
            +
                        subject.set_count_on_hand(7)
         | 
| 229 | 
            +
                      end.to change { subject.variant.updated_at }
         | 
| 230 | 
            +
                    end
         | 
| 231 | 
            +
             | 
| 232 | 
            +
                    it "count on hand stays below threshold" do
         | 
| 233 | 
            +
                      expect do
         | 
| 234 | 
            +
                        subject.set_count_on_hand(3)
         | 
| 235 | 
            +
                      end.to change { subject.variant.updated_at }
         | 
| 236 | 
            +
                    end
         | 
| 226 237 | 
             
                  end
         | 
| 227 238 | 
             
                end
         | 
| 228 239 |  | 
| @@ -255,6 +266,8 @@ describe Spree::StockItem, type: :model do | |
| 255 266 | 
             
              end
         | 
| 256 267 |  | 
| 257 268 | 
             
              describe "#after_touch" do
         | 
| 269 | 
            +
                before { subject.variant.update_column(:updated_at, 1.day.ago) }
         | 
| 270 | 
            +
             | 
| 258 271 | 
             
                it "touches its variant" do
         | 
| 259 272 | 
             
                  expect do
         | 
| 260 273 | 
             
                    subject.touch
         | 
| @@ -838,10 +838,10 @@ describe Spree::StoreCredit do | |
| 838 838 | 
             
                subject { store_credit.invalidate(invalidation_reason, invalidation_user) }
         | 
| 839 839 |  | 
| 840 840 | 
             
                it "sets the invalidated_at field to the current time" do
         | 
| 841 | 
            -
                  invalidated_at =  | 
| 841 | 
            +
                  invalidated_at = 2.minutes.from_now
         | 
| 842 842 | 
             
                  Timecop.freeze(invalidated_at) do
         | 
| 843 843 | 
             
                    subject
         | 
| 844 | 
            -
                    expect(store_credit.invalidated_at).to  | 
| 844 | 
            +
                    expect(store_credit.invalidated_at).to be_within(1.second).of invalidated_at
         | 
| 845 845 | 
             
                  end
         | 
| 846 846 | 
             
                end
         | 
| 847 847 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: solidus_core
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.0.0 | 
| 4 | 
            +
              version: 2.0.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Solidus Team
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2016-09- | 
| 11 | 
            +
            date: 2016-09-26 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activemerchant
         | 
| @@ -1404,9 +1404,9 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 1404 1404 | 
             
                  version: 2.1.0
         | 
| 1405 1405 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 1406 1406 | 
             
              requirements:
         | 
| 1407 | 
            -
              - - " | 
| 1407 | 
            +
              - - ">="
         | 
| 1408 1408 | 
             
                - !ruby/object:Gem::Version
         | 
| 1409 | 
            -
                  version:  | 
| 1409 | 
            +
                  version: '0'
         | 
| 1410 1410 | 
             
            requirements: []
         | 
| 1411 1411 | 
             
            rubyforge_project: 
         | 
| 1412 1412 | 
             
            rubygems_version: 2.5.1
         |