Sha256: f13fa4f600ad26f21cb60464d82ccaea1dc9d6d91cffbe80619b47af0218c86b

Contents?: true

Size: 1.34 KB

Versions: 64

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

module Spree
  describe Api::CountriesController, :type => :controller do
    render_views

    before do
      stub_authentication!
      @state = create(:state)
      @country = @state.country
    end

    it "gets all countries" do
      api_get :index
      expect(json_response['countries'].first['iso3']).to eq @country.iso3
    end

    context "with two countries" do
      before { @zambia = create(:country, :name => "Zambia") }

      it "can view all countries" do
        api_get :index
        expect(json_response['count']).to eq(2)
        expect(json_response['current_page']).to eq(1)
        expect(json_response['pages']).to eq(1)
      end

      it 'can query the results through a paramter' do
        api_get :index, :q => { :name_cont => 'zam' }
        expect(json_response['count']).to eq(1)
        expect(json_response['countries'].first['name']).to eq @zambia.name
      end

      it 'can control the page size through a parameter' do
        api_get :index, :per_page => 1
        expect(json_response['count']).to eq(1)
        expect(json_response['current_page']).to eq(1)
        expect(json_response['pages']).to eq(2)
      end
    end

    it "includes states" do
      api_get :show, :id => @country.id
      states = json_response['states']
      expect(states.first['name']).to eq @state.name
    end
  end
end

Version data entries

64 entries across 64 versions & 2 rubygems

Version Path
solidus_api-1.2.0.beta1 spec/controllers/spree/api/countries_controller_spec.rb
solidus_api-1.0.3 spec/controllers/spree/api/countries_controller_spec.rb
solidus_api-1.1.1 spec/controllers/spree/api/countries_controller_spec.rb
solidus_api-1.1.0 spec/controllers/spree/api/countries_controller_spec.rb
solidus_api-1.1.0.pre2 spec/controllers/spree/api/countries_controller_spec.rb
solidus_api-1.1.0.pre1 spec/controllers/spree/api/countries_controller_spec.rb
solidus_api-1.1.0.beta1 spec/controllers/spree/api/countries_controller_spec.rb
solidus_api-1.0.2 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-3.0.4 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.4.10 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.3.13 spec/controllers/spree/api/countries_controller_spec.rb
solidus_api-1.0.1 spec/controllers/spree/api/countries_controller_spec.rb
solidus_api-1.0.0 spec/controllers/spree/api/countries_controller_spec.rb
solidus_api-1.0.0.rc2 spec/controllers/spree/api/countries_controller_spec.rb
solidus_api-1.0.0.rc1 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-3.0.3 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.4.9 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.3.12 spec/controllers/spree/api/countries_controller_spec.rb
solidus_api-1.0.0.pre3 spec/controllers/spree/api/countries_controller_spec.rb
solidus_api-1.0.0.pre2 spec/controllers/spree/api/countries_controller_spec.rb