diff options
| -rw-r--r-- | app/controllers/v1/licenses_controller.rb | 4 | ||||
| -rw-r--r-- | spec/controllers/v1/liceneses_controller_spec.rb | 13 |
2 files changed, 12 insertions, 5 deletions
diff --git a/app/controllers/v1/licenses_controller.rb b/app/controllers/v1/licenses_controller.rb index d8c16b6..36ae54c 100644 --- a/app/controllers/v1/licenses_controller.rb +++ b/app/controllers/v1/licenses_controller.rb @@ -4,8 +4,8 @@ class V1::LicensesController < ApplicationController before_filter :prepare_pagination def index - @licenses = License.most_recent(@page, @per_page) - render nothing: true + @licenses = License.most_recent(page: @page, per_page: @per_page) + render json: @licenses end private diff --git a/spec/controllers/v1/liceneses_controller_spec.rb b/spec/controllers/v1/liceneses_controller_spec.rb index 5964556..b2eb705 100644 --- a/spec/controllers/v1/liceneses_controller_spec.rb +++ b/spec/controllers/v1/liceneses_controller_spec.rb @@ -5,7 +5,7 @@ describe V1::LicensesController do let(:licenses) { [] } it "returns the first page of licenses" do - License.stub(:most_recent).with(1, 10).and_return(licenses) + License.stub(:most_recent).with(page: 1, per_page: 10).and_return(licenses) xhr :get, :index @@ -14,7 +14,7 @@ describe V1::LicensesController do end it "returns the second page of licenses" do - License.stub(:most_recent).with(2, 10).and_return(licenses) + License.stub(:most_recent).with(page: 2, per_page: 10).and_return(licenses) xhr :get, :index, page: 2 @@ -23,11 +23,18 @@ describe V1::LicensesController do end it "returns the specified number of results" do - License.stub(:most_recent).with(1, 100).and_return(licenses) + 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 |
