blob: e8538d02e259455247c17dc5c5f5a0cdf440d901 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
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
describe :show do
let(:license) { License.new(id: SecureRandom.uuid) }
before :each do
License.stub(:find).with(license.id).and_return(license)
xhr :get, :show, id: license.id
end
it "returns the correct license" do
assigns(:license).should == license
end
it "returns a json response" do
expect(-> { JSON.parse(response.body) }).not_to raise_error
end
end
end
|