Sha256: 9e4d3a6ad7a98ae6bc426c17b96c5d475aeb8c2b040ac4a9cb7b2a86e64cdcb6

Contents?: true

Size: 1.01 KB

Versions: 31

Compression:

Stored size: 1.01 KB

Contents

require "rails_helper"

module Dorsale
  describe SmallData::FiltersController, type: :controller do
    routes { Dorsale::Engine.routes }

    let(:filters) { {key: "value"} }

    before(:each) do
      request.env["HTTP_REFERER"] = "where_i_came_from"
    end

    describe "create" do
      let(:action) {post :create, filters: filters}

      it "should redirect to refferer" do
        action
        expect(response).to redirect_to "where_i_came_from"
      end

      it "should redirect to call back url if defined" do
        post :create, filters: {key: "value"}, back_url: "xxx"
        expect(response).to redirect_to "xxx"
      end

      it "should store the filter in cookie" do
        action
        expect(response.cookies["filters"]).to eq(filters.to_json)
      end

      it "should merge filters with previous filters" do
        action
        post :create, filters: {other_key: "value2"}
        expect(response.cookies["filters"]).to eq({key: "value", other_key: "value2"}.to_json)
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
dorsale-2.2.6 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.2.5 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.2.4 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.2.3 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.2.2 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.2.1 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.2.0 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.1.15 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.1.14 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.1.13 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.1.12 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.1.11 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.1.10 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.1.9 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.1.8 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.1.7 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.1.6 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.1.5 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.1.4 spec/controllers/dorsale/small_data/filters_controller_spec.rb
dorsale-2.1.3 spec/controllers/dorsale/small_data/filters_controller_spec.rb