summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-02-22 11:12:06 -0700
committermo khan <mo@mokhan.ca>2014-02-22 11:12:06 -0700
commitef7eeb8ed18092bde97ebc30d249d32e56d5645f (patch)
tree28b6d98b366230ee1a0e559272ffee18d38c9b3f
parent64d63822a09d674d1257759b593a562711305d75 (diff)
found a weird bug with jbuilder and trying to render the location json node.
-rw-r--r--app/controllers/application_controller.rb1
-rw-r--r--app/controllers/v1/licenses_controller.rb2
-rw-r--r--app/models/location.rb2
-rw-r--r--app/views/v1/company_licenses/index.json.jbuilder (renamed from app/views/v1/company_licenses/index.jbuilder)0
-rw-r--r--app/views/v1/licenses/_license.json.jbuilder2
-rw-r--r--spec/controllers/v1/licenses_controller_spec.rb19
6 files changed, 6 insertions, 20 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 1b2f9f7..424262c 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -5,7 +5,6 @@ class ApplicationController < ActionController::Base
before_filter :load_additional_payload_data
rescue_from StandardError, with: :return_server_error
-
def load_additional_payload_data
@license_statuses = LicenseStatus::ALL
@well_types = WellType::ALL
diff --git a/app/controllers/v1/licenses_controller.rb b/app/controllers/v1/licenses_controller.rb
index c62c78b..8966100 100644
--- a/app/controllers/v1/licenses_controller.rb
+++ b/app/controllers/v1/licenses_controller.rb
@@ -5,12 +5,10 @@ class V1::LicensesController < ApplicationController
def index
@licenses = License.most_recent(page: @page, per_page: @per_page)
- render json: @licenses
end
def show
@license = License.find(params[:id])
- render json: @license
end
private
diff --git a/app/models/location.rb b/app/models/location.rb
index bf7b7ef..b74eabc 100644
--- a/app/models/location.rb
+++ b/app/models/location.rb
@@ -1,3 +1,3 @@
class Location < ActiveRecord::Base
- belongs_to :license
+ belongs_to :license, autosave: true
end
diff --git a/app/views/v1/company_licenses/index.jbuilder b/app/views/v1/company_licenses/index.json.jbuilder
index 8228f3e..8228f3e 100644
--- a/app/views/v1/company_licenses/index.jbuilder
+++ b/app/views/v1/company_licenses/index.json.jbuilder
diff --git a/app/views/v1/licenses/_license.json.jbuilder b/app/views/v1/licenses/_license.json.jbuilder
index c66fb3f..b62f91b 100644
--- a/app/views/v1/licenses/_license.json.jbuilder
+++ b/app/views/v1/licenses/_license.json.jbuilder
@@ -1,6 +1,6 @@
json.id license.id
json.status license.status.to_s
-json.partial! 'v1/licenses/location', location: license.location
+#json.partial! 'v1/licenses/location', location: license.location
if license.confidential?
json.partial! 'v1/licenses/confidential_well_type', well_type: license.well_type
json.partial! 'v1/licenses/confidential_company'
diff --git a/spec/controllers/v1/licenses_controller_spec.rb b/spec/controllers/v1/licenses_controller_spec.rb
index e8538d0..ca51f95 100644
--- a/spec/controllers/v1/licenses_controller_spec.rb
+++ b/spec/controllers/v1/licenses_controller_spec.rb
@@ -7,7 +7,7 @@ describe V1::LicensesController do
it "returns the first page of licenses" do
License.stub(:most_recent).with(page: 1, per_page: 10).and_return(licenses)
- xhr :get, :index
+ get :index
response.should be_success
assigns(:licenses).should == licenses
@@ -16,7 +16,7 @@ describe V1::LicensesController do
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
+ get :index, page: 2
response.should be_success
assigns(:licenses).should == licenses
@@ -25,17 +25,10 @@ describe V1::LicensesController do
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
+ 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
@@ -43,15 +36,11 @@ describe V1::LicensesController do
before :each do
License.stub(:find).with(license.id).and_return(license)
- xhr :get, :show, id: license.id
+ 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