Sha256: 91765c9eebd8db28a5791ef024b521184c7ab714133089410e2b02e8ccd32d8a

Contents?: true

Size: 984 Bytes

Versions: 6

Compression:

Stored size: 984 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "BasicController" do
  before(:each) do
    @people_controller = PeopleController.new
    
    10.times do |i|
      Fabricate(:person)
    end
    
    @params = {
      :searchable_columns => ["first_name", "last_name", "age", "date_of_birth", "gender"],
      :column_search => {},
      :limit => "5",
      :offset => "0",
      :search => "",
      :sort_column => "",
      :sort_direction => ""
    }
  end
  
  it "should have the jtable_for_json method" do
    @people_controller.respond_to?(:jtable_for_json).should be_true
  end
  
  it "should return the appropriate json" do
    people = Person.jtable_basic_query(@params)
    jtable_items = people.jtable_basic_paginate(@params[:limit], @params[:offset]).collect(&:jtable_basic_item)
    @people_controller.jtable_for_json(:basic, people, @params).to_json.should eql({:total_items => people.count, :items => jtable_items}.to_json)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jtable-rails-0.2.5 spec/controller_specs/basic_controller_spec.rb
jtable-rails-0.2.4 spec/controller_specs/basic_controller_spec.rb
jtable-rails-0.2.3 spec/controller_specs/basic_controller_spec.rb
jtable-rails-0.2.2 spec/controller_specs/basic_controller_spec.rb
jtable-rails-0.2.1 spec/controller_specs/basic_controller_spec.rb
jtable-rails-0.2.0 spec/controller_specs/basic_controller_spec.rb