Sha256: 9d0c8658840f6bc62458764bd873abcc0303467d1a4fb2a8f21da5f83dda7543

Contents?: true

Size: 1.07 KB

Versions: 48

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Spree::State, type: :model do
  describe '.with_name_or_abbr' do
    subject do
      Spree::State.with_name_or_abbr(search_term)
    end

    let!(:state) { create(:state, name: "California", abbr: "CA") }

    context 'by invalid term' do
      let(:search_term) { 'NonExistent' }
      it { is_expected.to be_empty }
    end

    context 'by name' do
      let(:search_term) { 'California' }
      it { is_expected.to include(state) }
    end

    context 'by abbr' do
      let(:search_term) { 'CA' }
      it { is_expected.to include(state) }
    end

    context 'by case-insensitive abbr' do
      let(:search_term) { 'CaLiFoRnIa' }
      it { is_expected.to include(state) }
    end

    context 'by case-insensitive abbr' do
      let(:search_term) { 'cA' }
      it { is_expected.to include(state) }
    end
  end

  it "can find all states group by country id" do
    state = create(:state)
    expect(Spree::State.states_group_by_country_id).to eq({ state.country_id.to_s => [[state.id, state.name]] })
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
solidus_core-2.10.5 spec/models/spree/state_spec.rb
solidus_core-2.10.3 spec/models/spree/state_spec.rb
solidus_core-2.10.2 spec/models/spree/state_spec.rb
solidus_core-2.9.6 spec/models/spree/state_spec.rb
solidus_core-2.8.6 spec/models/spree/state_spec.rb
solidus_core-2.10.1 spec/models/spree/state_spec.rb
solidus_core-2.9.5 spec/models/spree/state_spec.rb
solidus_core-2.10.0 spec/models/spree/state_spec.rb
solidus_core-2.9.4 spec/models/spree/state_spec.rb
solidus_core-2.6.6 spec/models/spree/state_spec.rb
solidus_core-2.7.4 spec/models/spree/state_spec.rb
solidus_core-2.8.5 spec/models/spree/state_spec.rb
solidus_core-2.9.3 spec/models/spree/state_spec.rb
solidus_core-2.9.2 spec/models/spree/state_spec.rb
solidus_core-2.10.0.beta1 spec/models/spree/state_spec.rb
solidus_core-2.7.3 spec/models/spree/state_spec.rb
solidus_core-2.6.5 spec/models/spree/state_spec.rb
solidus_core-2.9.1 spec/models/spree/state_spec.rb
solidus_core-2.9.0 spec/models/spree/state_spec.rb
solidus_core-2.9.0.rc.1 spec/models/spree/state_spec.rb