blob: b2eb705029dd95beb6f99b4708c2f1db4e1ec456 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
require "spec_helper"
describe V1::LicensesController do
describe :index do
let(:licenses) { [] }
it "returns the first page of licenses" do
License.stub(:most_recent).with(page: 1, per_page: 10).and_return(licenses)
xhr :get, :index
response.should be_success
assigns(:licenses).should == licenses
end
it "returns the second page of licenses" do
License.stub(:most_recent).with(page: 2, per_page: 10).and_return(licenses)
xhr :get, :index, page: 2
response.should be_success
assigns(:licenses).should == licenses
end
it "returns the specified number of results" do
License.stub(:most_recent).with(page: 1, per_page: 100).and_return(licenses)
xhr :get, :index, per_page: 100
response.should be_success
assigns(:licenses).should == licenses
end
it "returns a json response" do
License.stub(:most_recent).with(page: 1, per_page: 10).and_return(licenses)
xhr :get, :index
-> { JSON.parse(response.body) }.should_not raise_error
end
end
end
|