Sha256: e92cb12229d54fb72ad46e488a53e3702c006744757ca2313df614be2691e36f

Contents?: true

Size: 1.33 KB

Versions: 22

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

RSpec.describe "App action / Cookies", :app_integration do
  before do
    module TestApp
      class App < Hanami::App
      end
    end

    Hanami.app.instance_eval(&app_hook) if respond_to?(:app_hook)
    Hanami.app.prepare

    module TestApp
      class Action < Hanami::Action
      end
    end
  end

  subject(:action_class) { TestApp::Action }

  context "default configuration" do
    it "has cookie support enabled" do
      expect(action_class.ancestors).to include Hanami::Action::Cookies
    end
  end

  context "custom cookie options given in app-level config" do
    subject(:app_hook) {
      proc do
        config.actions.cookies = {max_age: 300}
      end
    }

    it "has cookie support enabled" do
      expect(action_class.ancestors).to include Hanami::Action::Cookies
    end

    it "has the cookie options configured" do
      expect(action_class.config.cookies).to eq(max_age: 300)
    end
  end

  context "cookies disabled in app-level config" do
    subject(:app_hook) {
      proc do
        config.actions.cookies = nil
      end
    }

    it "does not have cookie support enabled" do
      expect(action_class.ancestors.map(&:to_s)).not_to include "Hanami::Action::Cookies"
    end

    it "has no cookie options configured" do
      expect(action_class.config.cookies).to eq({})
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
hanami-2.2.1 spec/integration/action/cookies_spec.rb
hanami-2.2.0 spec/integration/action/cookies_spec.rb
hanami-2.2.0.rc1 spec/integration/action/cookies_spec.rb
hanami-2.2.0.beta2 spec/integration/action/cookies_spec.rb
hanami-2.2.0.beta1 spec/integration/action/cookies_spec.rb
hanami-2.1.0 spec/integration/action/cookies_spec.rb
hanami-2.1.0.rc3 spec/integration/action/cookies_spec.rb
hanami-2.1.0.rc2 spec/integration/action/cookies_spec.rb
hanami-2.1.0.rc1 spec/integration/action/cookies_spec.rb
hanami-2.1.0.beta2.1 spec/integration/action/cookies_spec.rb
hanami-2.1.0.beta2 spec/integration/action/cookies_spec.rb
hanami-2.1.0.beta1 spec/integration/action/cookies_spec.rb
hanami-2.0.3 spec/integration/action/cookies_spec.rb
hanami-2.0.2 spec/integration/action/cookies_spec.rb
hanami-2.0.1 spec/integration/action/cookies_spec.rb
hanami-2.0.0 spec/integration/action/cookies_spec.rb
hanami-2.0.0.rc1 spec/integration/action/cookies_spec.rb
hanami-2.0.0.beta4 spec/integration/action/cookies_spec.rb
hanami-2.0.0.beta3 spec/integration/action/cookies_spec.rb
hanami-2.0.0.beta2 spec/new_integration/action/cookies_spec.rb