Sha256: ddab4cf91ee5ccc0a1cd57a228712d611211cc02d310cbce9ea064a10e1e68c6

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe Spree::Admin::ShipCompliantSettingsController do
  stub_authorization!

   context '#edit' do
    it 'should assign a SolidusShipCompliant::Config and render the view' do
      get :edit

      expect(assigns(:config)).to be_an_instance_of(SolidusShipCompliant::Configuration)
      expect(response).to render_template('edit')
    end
  end

  context '#update' do
    let(:config) { SolidusShipCompliant::Config }

    context 'with existing value' do
      around do |example|
        default_weight = config.get_preference(:username)
        example.run
        config.set_preference(:username, default_weight)
      end

      it "updates the existing value" do
        expect(config.has_preference?(:username)).to be(true)
        post :update, params: { username: 'user_test' }
        expect(config.send("username")).to eql('user_test')
      end
    end

    context 'without existing value' do
      it "doesn't produce an error" do
        post :update, params: { 'not_real_parameter_name' => 'not_real' }
        expect(response).to redirect_to(spree.edit_admin_ship_compliant_settings_path)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_ship_compliant-1.0.0 spec/controllers/admin/ship_compliant_settings_controller_spec.rb