summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/v1/licenses_controller.rb8
-rw-r--r--app/models/license.rb2
-rw-r--r--spec/controllers/v1/liceneses_controller_spec.rb16
3 files changed, 25 insertions, 1 deletions
diff --git a/app/controllers/v1/licenses_controller.rb b/app/controllers/v1/licenses_controller.rb
index 697daa9..86eb85e 100644
--- a/app/controllers/v1/licenses_controller.rb
+++ b/app/controllers/v1/licenses_controller.rb
@@ -1,2 +1,8 @@
-class V1::LicensesController
+class V1::LicensesController < ApplicationController
+ def index
+ per_page = 10
+ page = 1
+ @licenses = License.most_recent(page, per_page)
+ render nothing: true
+ end
end
diff --git a/app/models/license.rb b/app/models/license.rb
new file mode 100644
index 0000000..4f7e5eb
--- /dev/null
+++ b/app/models/license.rb
@@ -0,0 +1,2 @@
+class License
+end
diff --git a/spec/controllers/v1/liceneses_controller_spec.rb b/spec/controllers/v1/liceneses_controller_spec.rb
new file mode 100644
index 0000000..fc4d7b3
--- /dev/null
+++ b/spec/controllers/v1/liceneses_controller_spec.rb
@@ -0,0 +1,16 @@
+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(1, 10).and_return(licenses)
+
+ xhr :get, :index
+
+ response.should be_success
+ assigns(:licenses).should == licenses
+ end
+ end
+end