Sha256: 4e209495c365329287decdaa9376369ec374da4d10c18230ac52847a452ab2e9

Contents?: true

Size: 720 Bytes

Versions: 2

Compression:

Stored size: 720 Bytes

Contents

require 'spec_helper'
require 'thoth/rails/railtie'

DummyUser = Struct.new(:id)
class ControllerWithThothContextController < ActionController::Base
  include Thoth::Rails::ControllerContext

  def show
    @context = Thoth.context
    head 200
  end

  def current_user
    DummyUser.new(1)
  end
end

describe ControllerWithThothContextController, type: :controller do
  before do
    routes.draw { get "show" => "controller_with_thoth_context#show" }
  end

  context "on any action" do
    it "stores params in the Thoth.context" do
      get :show
      expect(controller.view_context.assigns['context']).to eq({"controller"=>"controller_with_thoth_context", "action"=>"show", "current_user"=>1})
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thoth-3.0.0 spec/thoth/rails/controller_context_spec.rb
thoth-2.0.0 spec/thoth/rails/controller_context_spec.rb