diff options
| author | mo khan <mo@mokhan.ca> | 2014-02-21 21:03:56 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-02-21 21:03:56 -0700 |
| commit | 4f6de445141fc5542f61a1830c29ad61ecbeb49b (patch) | |
| tree | d769b60454e95cdf63ff741dff4375bfb3a80d3e | |
| parent | f6eebdeb6aa56c4734102caf1817479d9e7b2765 (diff) | |
load well statuses and well types in application controller.
| -rw-r--r-- | app/controllers/application_controller.rb | 8 | ||||
| -rw-r--r-- | app/controllers/v1/company_licenses_controller.rb | 6 | ||||
| -rw-r--r-- | spec/controllers/application_controller_spec.rb | 19 | ||||
| -rw-r--r-- | spec/controllers/v1/company_licenses_controller_spec.rb | 10 |
4 files changed, 26 insertions, 17 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d83690e..658a065 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,11 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. - protect_from_forgery with: :exception + protect_from_forgery with: :null_session + before_filter :load_additional_payload_data + + def load_additional_payload_data + @license_statuses = LicenseStatus::ALL + @well_types = WellType::ALL + end end diff --git a/app/controllers/v1/company_licenses_controller.rb b/app/controllers/v1/company_licenses_controller.rb index df0c4ec..234345c 100644 --- a/app/controllers/v1/company_licenses_controller.rb +++ b/app/controllers/v1/company_licenses_controller.rb @@ -1,6 +1,5 @@ class V1::CompanyLicensesController < ApplicationController before_filter :load_company - before_filter :load_additional_payload_data def index @active_licenses = filter_using(@company, search_filters) @@ -22,9 +21,4 @@ class V1::CompanyLicensesController < ApplicationController def load_company @company = Company.find(params[:company_id]) end - - def load_additional_payload_data - @license_statuses = LicenseStatus::ALL - @well_types = WellType::ALL - end end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb new file mode 100644 index 0000000..a26c465 --- /dev/null +++ b/spec/controllers/application_controller_spec.rb @@ -0,0 +1,19 @@ +require "spec_helper" + +describe ApplicationController do + controller do + def index + render nothing: true + end + end + + it "includes all well statuses with every response" do + get :index + assigns(:license_statuses).should =~ LicenseStatus::ALL + end + + it "includes all well types with every response" do + get :index + assigns(:well_types).should =~ WellType::ALL + end +end diff --git a/spec/controllers/v1/company_licenses_controller_spec.rb b/spec/controllers/v1/company_licenses_controller_spec.rb index c139f8b..2784a1d 100644 --- a/spec/controllers/v1/company_licenses_controller_spec.rb +++ b/spec/controllers/v1/company_licenses_controller_spec.rb @@ -27,15 +27,5 @@ describe V1::CompanyLicensesController do xhr :get, :index, company_id: company_id, township: "123" assigns(:active_licenses).should == active_licenses_in_township end - - it "includes each well status" do - xhr :get, :index, company_id: company_id - assigns(:license_statuses).should =~ LicenseStatus::ALL - end - - it "includes each well type" do - xhr :get, :index, company_id: company_id - assigns(:well_types).should =~ WellType::ALL - end end end |
