Sha256: 8409ede3a42476a5462ae5b206f1b52337e870e442edbcf18deb5528c8122e99

Contents?: true

Size: 1.83 KB

Versions: 26

Compression:

Stored size: 1.83 KB

Contents

require 'spec_helper'

describe "States", type: :feature do
  stub_authorization!

  let!(:country) { create(:country) }

  let!(:hungary) do
    Spree::Country.create!(name: "Hungary", iso_name: "Hungary")
  end

  def go_to_states_page
    visit spree.admin_country_states_path(country)
    expect(page).to have_css("#new_state_link")
  end

  context "admin visiting states listing" do
    let!(:state) { create(:state, country: country) }

    it "should correctly display the states" do
      visit spree.admin_country_states_path(country)
      expect(page).to have_content(state.name)
    end
  end

  context "creating and editing states" do
    it "should allow an admin to edit existing states", js: true do
      go_to_states_page
      select2 country.name, from: 'Country'

      click_link "new_state_link"
      fill_in "state_name", with: "Calgary"
      fill_in "Abbreviation", with: "CL"
      click_button "Create"
      expect(page).to have_content("successfully created!")
      expect(page).to have_content("Calgary")
    end

    it "should allow an admin to create states for non default countries", js: true do
      go_to_states_page
      select2 hungary.name, from: 'Country'

      click_link "new_state_link"
      fill_in "state_name", with: "Pest megye"
      fill_in "Abbreviation", with: "PE"
      click_button "Create"
      expect(page).to have_content("successfully created!")
      expect(page).to have_content("Pest megye")
      expect(find("#s2id_country")).to have_content("Hungary")
    end

    it "should show validation errors", js: true do
      go_to_states_page
      select2 country.name, from: 'Country'

      click_link "new_state_link"

      fill_in "state_name", with: ""
      fill_in "Abbreviation", with: ""
      click_button "Create"
      expect(page).to have_content("Name can't be blank")
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
solidus_backend-2.2.2 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.1.1 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.0.3 spec/features/admin/configuration/states_spec.rb
solidus_backend-1.4.2 spec/features/admin/configuration/states_spec.rb
solidus_backend-1.3.2 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.0.2 spec/features/admin/configuration/states_spec.rb
solidus_backend-1.4.1 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.2.1 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.2.0 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.2.0.rc1 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.2.0.beta1 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.1.0 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.1.0.rc1 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.0.1 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.1.0.beta1 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.0.0 spec/features/admin/configuration/states_spec.rb
solidus_backend-1.4.0 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.0.0.rc1 spec/features/admin/configuration/states_spec.rb
solidus_backend-1.4.0.rc1 spec/features/admin/configuration/states_spec.rb
solidus_backend-2.0.0.beta1 spec/features/admin/configuration/states_spec.rb