Add filters to SDG relations controller

We have three filters: "pending", "all" and "reviewed". Where "pending"
is the default one.

Now we are rendering the `shared/_filter_subnav` partial we need to stub
helper methods defined at the controller and the helper methods that
rely on the request parameters to test the component.
This commit is contained in:
Senén Rodero Rodríguez
2020-12-21 18:17:36 +01:00
parent 94a4b67675
commit c6407d82e3
8 changed files with 70 additions and 0 deletions

View File

@@ -2,8 +2,12 @@ class SDGManagement::RelationsController < SDGManagement::BaseController
before_action :check_feature_flags
before_action :load_record, only: [:edit, :update]
FILTERS = %w[pending_sdg_review all sdg_reviewed].freeze
has_filters FILTERS, only: :index
def index
@records = relatable_class
.send(@current_filter)
.accessible_by(current_ability)
.by_goal(params[:goal_code])
.by_target(params[:target_code])