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_devise_token_auth-2.8.0.alpha.4 spec/models/spree/state_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.3 spec/models/spree/state_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.1 spec/models/spree/state_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.0 spec/models/spree/state_spec.rb
solidus_core-2.7.0 spec/models/spree/state_spec.rb
solidus_core-2.6.1 spec/models/spree/state_spec.rb
solidus_core-2.6.0 spec/models/spree/state_spec.rb
solidus_core-2.6.0.rc1 spec/models/spree/state_spec.rb