Sha256: 8944ae62124e102c5522ebf26ac9481471c4f096d542fcafd6c548c5cc494901

Contents?: true

Size: 1.02 KB

Versions: 34

Compression:

Stored size: 1.02 KB

Contents

require 'rails_helper'

# RSpec.configure do |c|
#   c.infer_base_class_for_anonymous_controllers = false
# end

describe ApplicationController, type: :controller do
  controller do
    def index
      tabulatr_for Product
    end

    def current_user
      "Han Solo"
    end
  end

  describe "passing locales to Tabulatr::Data" do
    it "implicitly creates a current_user local if not already present" do
      request.accept = "application/json"
      Product.create!(:title => 'bar', :active => true, :price => 10.0)
      fake_response = double({foo: 'bar'})

      expect_any_instance_of(Tabulatr::Data).to receive(:data_for_table).with(
        {"pagesize"=>"20", "arguments"=>"products:title", "controller"=>"anonymous", "action"=>"index"},
        {:locals=>{current_user: "Han Solo"}, controller: controller}
      ).and_return(fake_response)
      expect(fake_response).to receive(:to_tabulatr_json).and_return({})

      get :index, pagesize: 20, arguments: 'products:title'
      expect(response.code).to eq '200'
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
tabulatr2-0.10.4 spec/controller/application_controller_spec.rb
tabulatr2-0.10.3 spec/controller/application_controller_spec.rb
tabulatr2-0.10.2 spec/controller/application_controller_spec.rb
tabulatr2-0.10.1 spec/controller/application_controller_spec.rb
tabulatr2-0.10.0 spec/controller/application_controller_spec.rb
tabulatr2-0.9.48 spec/controller/application_controller_spec.rb
tabulatr2-0.9.47 spec/controller/application_controller_spec.rb
tabulatr2-0.9.46 spec/controller/application_controller_spec.rb
tabulatr2-0.9.45 spec/controller/application_controller_spec.rb
tabulatr2-0.9.44 spec/controller/application_controller_spec.rb
tabulatr2-0.9.43 spec/controller/application_controller_spec.rb
tabulatr2-0.9.42 spec/controller/application_controller_spec.rb
tabulatr2-0.9.41 spec/controller/application_controller_spec.rb
tabulatr2-0.9.40 spec/controller/application_controller_spec.rb
tabulatr2-0.9.39 spec/controller/application_controller_spec.rb
tabulatr2-0.9.38 spec/controller/application_controller_spec.rb
tabulatr2-0.9.37 spec/controller/application_controller_spec.rb
tabulatr2-0.9.36 spec/controller/application_controller_spec.rb
tabulatr2-0.9.35 spec/controller/application_controller_spec.rb
tabulatr2-0.9.34 spec/controller/application_controller_spec.rb