4848class TestApplication < Rails ::Application
4949 config . root = __dir__
5050 config . session_store :cookie_store , key : 'cookie_store_key'
51- secrets . secret_token = 'secret_token'
52- secrets . secret_key_base = 'secret_key_base'
51+ config . secret_key_base = 'secret_key_base_for_testing_only'
5352
5453 config . eager_load = false
5554 config . logger = ActiveRecord ::Base . logger
5655
5756 config . hosts = %w[ 127.0.0.1 ]
5857
5958 # Configure sprockets assets
60- config . assets . paths = [ File . join ( config . root , 'assets' ) ]
59+ config . assets . paths = [ File . join ( config . root , 'app' , ' assets' , 'stylesheets' ) , File . join ( config . root , 'app' , 'assets' , 'javascripts ') ]
6160 config . assets . unknown_asset_fallback = false
6261 config . assets . digest = false
6362 config . assets . debug = false
6463 config . assets . compile = true
64+
6565 # config.public_file_server.enabled
6666end
6767
@@ -91,12 +91,16 @@ def log_error(error, causes: [])
9191 return if error . cause . nil? || error . cause == error || causes . include? ( error . cause )
9292
9393 causes . push ( error )
94- log_error ( error , causes )
94+ log_error ( error . cause , causes : causes )
9595 end
9696end
9797
9898class User < ActiveRecord ::Base
9999 validates :full_name , presence : true
100+
101+ def self . ransackable_attributes ( auth_object = nil )
102+ %w[ id full_name created_at updated_at ]
103+ end
100104end
101105
102106module Billing
@@ -105,6 +109,14 @@ class Employee < ActiveRecord::Base
105109 accepts_nested_attributes_for :duties
106110 validates :full_name , presence : true
107111 validates :salary , numericality : { greater_than_or_equal_to : 0.01 }
112+
113+ def self . ransackable_attributes ( auth_object = nil )
114+ %w[ id full_name salary created_at updated_at ]
115+ end
116+
117+ def self . ransackable_associations ( auth_object = nil )
118+ %w[ duties ]
119+ end
108120 end
109121
110122 class Duty < ActiveRecord ::Base
@@ -115,6 +127,14 @@ class Duty < ActiveRecord::Base
115127 def common?
116128 duty_type == 'common'
117129 end
130+
131+ def self . ransackable_attributes ( auth_object = nil )
132+ %w[ id name duty_type employee_id created_at updated_at ]
133+ end
134+
135+ def self . ransackable_associations ( auth_object = nil )
136+ %w[ employee ]
137+ end
118138 end
119139end
120140
0 commit comments