diff --git a/app/avo/resources/feed.rb b/app/avo/resources/feed.rb index c1204cd..d15e271 100644 --- a/app/avo/resources/feed.rb +++ b/app/avo/resources/feed.rb @@ -1,9 +1,9 @@ class Avo::Resources::Feed < Avo::BaseResource # self.includes = [] # self.attachments = [] - # self.search = { - # query: -> { query.ransack(id_eq: params[:q], m: "or").result(distinct: false) } - # } + self.search = { + query: -> { query.ransack(title_cont: params[:q], m: "or").result(distinct: false) } + } def fields field :id, as: :id diff --git a/app/avo/resources/minister.rb b/app/avo/resources/minister.rb index 62a6355..77dc23b 100644 --- a/app/avo/resources/minister.rb +++ b/app/avo/resources/minister.rb @@ -1,10 +1,10 @@ class Avo::Resources::Minister < Avo::BaseResource # self.includes = [] # self.attachments = [] - # self.search = { - # query: -> { query.ransack(id_eq: params[:q], m: "or").result(distinct: false) } - # } - # + self.search = { + query: -> { query.ransack(first_name_cont: params[:q], last_name_cont: params[:q], title_cont: params[:q], m: "or").result(distinct: false) } + } + self.title = :compound_name def fields diff --git a/app/avo/resources/promise.rb b/app/avo/resources/promise.rb index 3e883a9..cfccd40 100644 --- a/app/avo/resources/promise.rb +++ b/app/avo/resources/promise.rb @@ -1,9 +1,9 @@ class Avo::Resources::Promise < Avo::BaseResource # self.includes = [] # self.attachments = [] - # self.search = { - # query: -> { query.ransack(id_eq: params[:q], m: "or").result(distinct: false) } - # } + self.search = { + query: -> { query.ransack(concise_title_cont: params[:q], m: "or").result(distinct: false) } + } self.title = :concise_title diff --git a/app/models/feed.rb b/app/models/feed.rb index 9a30554..ffa339c 100644 --- a/app/models/feed.rb +++ b/app/models/feed.rb @@ -3,6 +3,10 @@ class Feed < ApplicationRecord has_many :entries, dependent: :destroy + def self.ransackable_attributes(auth_object = nil) + [ "title" ] + end + def refresh! # Implement the logic to refresh the feed data response = HTTP.get(url) diff --git a/app/models/minister.rb b/app/models/minister.rb index b399afa..53b08e8 100644 --- a/app/models/minister.rb +++ b/app/models/minister.rb @@ -2,8 +2,12 @@ class Minister < ApplicationRecord belongs_to :government belongs_to :department + def self.ransackable_attributes(auth_object = nil) + [ "first_name", "last_name", "title" ] + end + def compound_name - "{title} (#{full_name})" + "#{title} (#{full_name})" end def full_name diff --git a/app/models/promise.rb b/app/models/promise.rb index 4f03fe5..c6c3e34 100644 --- a/app/models/promise.rb +++ b/app/models/promise.rb @@ -8,6 +8,10 @@ class Promise < ApplicationRecord has_one :lead_department_promise, -> { where(is_lead: true) }, class_name: "DepartmentPromise" has_one :lead_department, through: :lead_department_promise, source: :department + def self.ransackable_attributes(auth_object = nil) + [ "concise_title" ] + end + def set_last_evidence_date! self.last_evidence_date = evidences.where.not(impact: "neutral").map(&:activity).maximum(:published_at) self.save!(touch: false) diff --git a/test/models/minister_test.rb b/test/models/minister_test.rb index 0c05015..47befc4 100644 --- a/test/models/minister_test.rb +++ b/test/models/minister_test.rb @@ -1,8 +1,8 @@ require "test_helper" class MinisterTest < ActiveSupport::TestCase - # test "that each department has a minister" do - # # Ensure that each department has - # assert_equal 0, Department.all.select { |d| d.minister.nil? }.count - # end + test "that compound_name is correct" do + minister = ministers(:finance_minister) + assert_equal "Deputy Prime Minister and Minister of Finance (Chrystia Freeland)", minister.compound_name + end end