diff --git a/app/models/group.rb b/app/models/group.rb index c442cf52..9296fc00 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -12,6 +12,7 @@ class Group < ApplicationRecord has_many :groups_permissions, class_name: 'GroupsPermissions', dependent: :destroy has_many :permissions, through: :groups_permissions has_many :mail_aliases + has_many :articles scope :active, (lambda { joins(:memberships).merge(Membership.active).distinct diff --git a/app/resources/v1/group_resource.rb b/app/resources/v1/group_resource.rb index 119784e0..976e5fd6 100644 --- a/app/resources/v1/group_resource.rb +++ b/app/resources/v1/group_resource.rb @@ -18,6 +18,7 @@ def description_camofied has_many :memberships has_many :mail_aliases has_many :permissions + has_many :articles filter :active, apply: ->(records, _value, _options) { records.active } filter :kind diff --git a/db/schema.rb b/db/schema.rb index 3c73c96e..e3514de9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,6 @@ # migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. - ActiveRecord::Schema[7.0].define(version: 2024_11_13_091607) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/spec/resources/v1/group_resource_spec.rb b/spec/resources/v1/group_resource_spec.rb index bd5f18d5..606e0f1b 100644 --- a/spec/resources/v1/group_resource_spec.rb +++ b/spec/resources/v1/group_resource_spec.rb @@ -7,8 +7,8 @@ describe '#fetchable_fields' do let(:basic_fields) do - %i[id name avatar_url avatar_thumb_url created_at updated_at mail_aliases memberships users - permissions] + %i[id name articles avatar_url avatar_thumb_url created_at updated_at mail_aliases + memberships users permissions] end let(:authenticated_fields) do %i[description description_camofied kind recognized_at_gma rejected_at_gma administrative]