Skip to content

Commit

Permalink
allow fetching of articles that a group has published (#377)
Browse files Browse the repository at this point in the history
* allow fetching of articles that a group has published

* this was probably redundant

* undo schema changes?

* fix schema by resetting db and rerunning db:migrate

* fix tests by adding attribute

* Fixed lint

* Fixed lint v2.rb

---------

Co-authored-by: lodewiges <131907615+lodewiges@users.noreply.github.com>
  • Loading branch information
DrumsnChocolate and lodewiges authored Jan 19, 2025
1 parent d73a101 commit 8e7034e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/models/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/resources/v1/group_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions spec/resources/v1/group_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 8e7034e

Please sign in to comment.