summaryrefslogtreecommitdiff
path: root/spec/controllers/v1/licenses_controller_spec.rb
blob: ca51f95bef62e17ae3ea14fae737d94dbf0698cf (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
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)

      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)

      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)

      get :index, per_page: 100
      response.should be_success
      assigns(:licenses).should == licenses
    end
  end

  describe :show do
    let(:license) { License.new(id: SecureRandom.uuid) }

    before :each do
      License.stub(:find).with(license.id).and_return(license)
      get :show, id: license.id
    end

    it "returns the correct license" do
      assigns(:license).should == license
    end
  end
end