2015-03-16 15:14:33 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe DirectoryItemsController do
|
|
|
|
|
2015-03-19 11:48:16 -04:00
|
|
|
it "requires a `period` param" do
|
2015-03-16 15:14:33 -04:00
|
|
|
->{ xhr :get, :index }.should raise_error
|
|
|
|
end
|
|
|
|
|
2015-03-19 11:48:16 -04:00
|
|
|
it "requires a proper `period` param" do
|
|
|
|
xhr :get, :index, period: 'eviltrout'
|
2015-03-16 15:14:33 -04:00
|
|
|
response.should_not be_success
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with data" do
|
|
|
|
before do
|
|
|
|
Fabricate(:user)
|
|
|
|
DirectoryItem.refresh!
|
|
|
|
end
|
|
|
|
|
|
|
|
it "succeeds with a valid value" do
|
2015-03-19 11:48:16 -04:00
|
|
|
xhr :get, :index, period: 'all'
|
2015-03-16 15:14:33 -04:00
|
|
|
response.should be_success
|
|
|
|
json = ::JSON.parse(response.body)
|
|
|
|
|
|
|
|
json.should be_present
|
|
|
|
json['directory_items'].should be_present
|
|
|
|
json['total_rows_directory_items'].should be_present
|
|
|
|
json['load_more_directory_items'].should be_present
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|