Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memberships API #725

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions app/controllers/api/v1/memberships_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Api::V1::MembershipsController < Api::V1::ApplicationController
include Api::V1::Memberships::ControllerBase

private

def permitted_fields
[
# 🚅 super scaffolding will insert new fields above this line.
]
end

def permitted_arrays
{
# 🚅 super scaffolding will insert new arrays above this line.
}
end

def process_params(strong_params)
strong_params
end
end
16 changes: 16 additions & 0 deletions app/views/api/v1/memberships/_membership.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
json.extract! membership,
:id,
:user_id,
:team_id,
:invitation_id,
:user_first_name,
:user_last_name,
:user_profile_photo_id,
:user_email,
:added_by_id,
:platform_agent_of_id,
:role_ids,
:platform_agent,
# 🚅 super scaffolding will insert new fields above this line.
:created_at,
:updated_at
2 changes: 2 additions & 0 deletions app/views/api/v1/open_api/index.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ components:
schemas:
<%= automatic_components_for Team %>
<%= automatic_components_for User %>
<%= automatic_components_for Membership %>
<%= automatic_components_for Webhooks::Outgoing::Endpoint %>
<%= automatic_components_for Webhooks::Outgoing::Event %>
<%= automatic_components_for Scaffolding::CompletelyConcrete::TangibleThing unless scaffolding_things_disabled? %>
Expand Down Expand Up @@ -49,6 +50,7 @@ security:
paths:
<%= paths_for Team %>
<%= paths_for User %>
<%= automatic_paths_for Membership, Team %>
<%= automatic_paths_for Webhooks::Outgoing::Endpoint, Team %>
<%= automatic_paths_for Webhooks::Outgoing::Event, Team, except: %i[create update delete] %>
<%= automatic_paths_for Scaffolding::CompletelyConcrete::TangibleThing, Scaffolding::AbsolutelyAbstract::CreativeConcept unless scaffolding_things_disabled? %>
Expand Down
14 changes: 14 additions & 0 deletions test/factories/memberships.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,19 @@
factory :membership do
association :user
association :team

factory :membership_example do
team { FactoryBot.example(:team) }
user { FactoryBot.example(:user, teams: [team]) }
invitation_id { nil }
user_first_name { user.first_name }
user_last_name { user.last_name }
user_profile_photo_id { 1 }
user_email { user.email }
added_by_id { FactoryBot.example(:user).id }
platform_agent_of_id { nil }
platform_agent { false }
role_ids { ["admin"] }
end
end
end
Loading