Sha256: 0631b0b14ab01b675cc2bba22f854a9df51bc50f842d7ecde150a667710b5391

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe Spree::Admin::ActiveShippingSettingsController do
  stub_authorization!

  context '#edit' do
    it 'should assign a Spree::ActiveShippingConfiguration and render the view' do
      spree_get :edit
      expect(assigns(:config)).to be_an_instance_of(Spree::ActiveShippingConfiguration)
      expect(response).to render_template('edit')
    end
  end

  context '#update' do
    let(:config) { Spree::ActiveShippingConfiguration.new }

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

      it "updates the existing value" do
        expect(config.has_preference?(:default_weight)).to be(true)
        spree_post :update, default_weight: 42
        expect(config.send("preferred_default_weight")).to be(42)
      end
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_active_shipping-1.0.0 spec/controllers/admin/active_shipping_settings_controller_spec.rb