Sha256: 5aa3faaf52e0c3685551cce79fb02a87688ce46d85a04e79fc0efee5beaf6a5d
Contents?: true
Size: 1.03 KB
Versions: 6
Compression:
Stored size: 1.03 KB
Contents
require 'spec_helper' 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
6 entries across 6 versions & 1 rubygems