Sha256: 0e9807aa6a3c9492bdb020d049e0a4ab61ae74633cf08ed1a9b3b0c0908955c6

Contents?: true

Size: 959 Bytes

Versions: 2

Compression:

Stored size: 959 Bytes

Contents

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

describe "PeopleController" 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_query(@params)
    jtable_items = people.jtable_paginate(@params[:limit], @params[:offset]).collect(&:jtable_item)
    @people_controller.jtable_for_json(people, @params).to_json.should eql({:total_items => people.count, :items => jtable_items}.to_json)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jtable-rails-0.1.4 spec/controller_specs/people_controller_spec.rb
jtable-rails-0.1.3 spec/controller_specs/people_controller_spec.rb