Sha256: 4a2b2d921ac102c614335f68603e2fdd5812ff090badb2e4299fe2b39e0d3e4c

Contents?: true

Size: 968 Bytes

Versions: 12

Compression:

Stored size: 968 Bytes

Contents

require 'spec_helper'

describe Alchemy::Admin::BaseController do

  describe '#options_from_params' do
    subject { controller.send(:options_from_params) }

    context "params[:options] is a JSON string" do
      before { controller.stub(:params).and_return(options: '{"hallo":"World"}') }

      it "parses the string into an object" do
        expect(subject).to be_an_instance_of(Hash)
        expect(subject).to eq({hallo: 'World'})
      end
    end

    context "params[:options] is already an object" do
      before { controller.stub(:params).and_return(options: {hallo: "World"}) }

      it "parses the string into an object" do
        expect(subject).to be_an_instance_of(Hash)
      end
    end

    context "params[:options] is not present" do
      before { controller.stub(:params).and_return({}) }

      it "returns ampty object" do
        expect(subject).to be_an_instance_of(Hash)
        expect(subject).to eq({})
      end
    end
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
alchemy_cms-2.9.1 spec/controllers/admin/base_controller_spec.rb
alchemy_cms-2.9.0 spec/controllers/admin/base_controller_spec.rb
alchemy_cms-2.8.3 spec/controllers/admin/base_controller_spec.rb
alchemy_cms-2.7.5 spec/controllers/admin/base_controller_spec.rb
alchemy_cms-2.7.4 spec/controllers/admin/base_controller_spec.rb
alchemy_cms-2.8.2 spec/controllers/admin/base_controller_spec.rb
alchemy_cms-2.8.1 spec/controllers/admin/base_controller_spec.rb
alchemy_cms-2.7.3 spec/controllers/admin/base_controller_spec.rb
alchemy_cms-3.0.0.rc5 spec/controllers/admin/base_controller_spec.rb
alchemy_cms-2.7.2 spec/controllers/admin/base_controller_spec.rb
alchemy_cms-2.7.1 spec/controllers/admin/base_controller_spec.rb
alchemy_cms-2.7.0 spec/controllers/admin/base_controller_spec.rb