summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-02-22 00:27:11 -0700
committermo khan <mo@mokhan.ca>2014-02-22 00:27:11 -0700
commitc76e1f97aec3c59cd5e3563e660bbb8905e64136 (patch)
tree3cedc47880069a31cc72cf05de3a6a4141fc11d6
parent3db1f24191ff0a5c1638b5f89e1f0ed595185cd8 (diff)
start view specs for each json response.
-rw-r--r--app/views/v1/licenses/index.jbuilder9
-rw-r--r--app/views/v1/licenses/show.jbuilder2
-rw-r--r--spec/views/v1/licenses/index.json.jbuilder_spec.rb17
-rw-r--r--spec/views/v1/licenses/show.json.jbuilder_spec.rb17
4 files changed, 45 insertions, 0 deletions
diff --git a/app/views/v1/licenses/index.jbuilder b/app/views/v1/licenses/index.jbuilder
new file mode 100644
index 0000000..ff31792
--- /dev/null
+++ b/app/views/v1/licenses/index.jbuilder
@@ -0,0 +1,9 @@
+json.array! @licenses do |license|
+ json.issued_at license.issued_at.to_s
+ json.expired_at license.expired_at.to_s
+ json.well_type do
+ json.id 1
+ json.pneumonic "NFW"
+ json.name "New Field Wildcat"
+ end
+end
diff --git a/app/views/v1/licenses/show.jbuilder b/app/views/v1/licenses/show.jbuilder
new file mode 100644
index 0000000..98f59e8
--- /dev/null
+++ b/app/views/v1/licenses/show.jbuilder
@@ -0,0 +1,2 @@
+json.issued_at @license.issued_at.to_s
+json.expired_at @license.expired_at.to_s
diff --git a/spec/views/v1/licenses/index.json.jbuilder_spec.rb b/spec/views/v1/licenses/index.json.jbuilder_spec.rb
new file mode 100644
index 0000000..d2583a3
--- /dev/null
+++ b/spec/views/v1/licenses/index.json.jbuilder_spec.rb
@@ -0,0 +1,17 @@
+require "spec_helper"
+
+describe 'v1/licenses/index' do
+ let!(:license) { License.create(issued_at: 2.days.ago, expired_at: 1.day.from_now) }
+
+ before :each do
+ assign(:licenses, License.all)
+ render
+ end
+
+ let(:result) { JSON.parse(rendered) }
+
+ it "includes the license date range" do
+ result.first["issued_at"].should == license.issued_at.to_s
+ result.first["expired_at"].should == license.expired_at.to_s
+ end
+end
diff --git a/spec/views/v1/licenses/show.json.jbuilder_spec.rb b/spec/views/v1/licenses/show.json.jbuilder_spec.rb
new file mode 100644
index 0000000..e4b337c
--- /dev/null
+++ b/spec/views/v1/licenses/show.json.jbuilder_spec.rb
@@ -0,0 +1,17 @@
+require "spec_helper"
+
+describe 'v1/licenses/show' do
+ let!(:license) { License.create(issued_at: 2.days.ago, expired_at: 1.day.from_now) }
+
+ before :each do
+ assign(:license, license)
+ render
+ end
+
+ let(:result) { JSON.parse(rendered) }
+
+ it "includes the license date range" do
+ result["issued_at"].should == license.issued_at.to_s
+ result["expired_at"].should == license.expired_at.to_s
+ end
+end