Sha256: 910d9a38d662cf687d88ce28fa04592206370f1b923abd2943558a057313bcad

Contents?: true

Size: 1.28 KB

Versions: 59

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

module Spree
  describe Api::CountriesController do
    render_views

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

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

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

      it "can view all countries" do
        api_get :index
        json_response['count'].should == 2
        json_response['current_page'].should == 1
        json_response['pages'].should == 1
      end

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

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

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

Version data entries

59 entries across 59 versions & 2 rubygems

Version Path
spree_api-2.2.14 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.2.13 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.2.12 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.2.11 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.2.10 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.2.9 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.1.12 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.2.8 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.1.11 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.2.7 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.1.10 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.0.13 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.4.0.rc2 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.4.0.rc1 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.3.4 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.1.9 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.2.6 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.3.3 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.3.2 spec/controllers/spree/api/countries_controller_spec.rb
spree_api-2.2.5 spec/controllers/spree/api/countries_controller_spec.rb