mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 20:05:55 +08:00
update endpoint type
This commit is contained in:
parent
debff7bc85
commit
3d79dd32ad
3 changed files with 10 additions and 10 deletions
|
@ -71,7 +71,7 @@ module Api
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_project_params
|
def user_project_params
|
||||||
raise TypeError unless params.require(:data).require(:type) == 'user_projects'
|
raise TypeError unless params.require(:data).require(:type) == 'project_user_assignments'
|
||||||
|
|
||||||
params.require(:data).require(:attributes).permit(:user_id, :user_role_id)
|
params.require(:data).require(:attributes).permit(:user_id, :user_role_id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
module Api
|
module Api
|
||||||
module V1
|
module V1
|
||||||
class ProjectUserAssignmentSerializer < ActiveModel::Serializer
|
class ProjectUserAssignmentSerializer < ActiveModel::Serializer
|
||||||
type :user_projects
|
type :project_user_assignments
|
||||||
attributes :id
|
attributes :id
|
||||||
|
|
||||||
belongs_to :user, serializer: UserSerializer
|
belongs_to :user, serializer: UserSerializer
|
||||||
|
|
|
@ -97,7 +97,7 @@ RSpec.describe "Api::V1::ProjectUserAssignmentsController", type: :request do
|
||||||
let(:request_body) do
|
let(:request_body) do
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
type: 'user_projects',
|
type: 'project_user_assignments',
|
||||||
attributes: {
|
attributes: {
|
||||||
user_id: @another_user.id,
|
user_id: @another_user.id,
|
||||||
user_role_id: @normal_user_role.id
|
user_role_id: @normal_user_role.id
|
||||||
|
@ -122,7 +122,7 @@ RSpec.describe "Api::V1::ProjectUserAssignmentsController", type: :request do
|
||||||
expect(json).to match(
|
expect(json).to match(
|
||||||
hash_including(
|
hash_including(
|
||||||
data: hash_including(
|
data: hash_including(
|
||||||
type: 'user_projects',
|
type: 'project_user_assignments',
|
||||||
relationships: hash_including(
|
relationships: hash_including(
|
||||||
user: hash_including(data: hash_including(id: @another_user.id.to_s)),
|
user: hash_including(data: hash_including(id: @another_user.id.to_s)),
|
||||||
user_role: hash_including(data: hash_including(id: @normal_user_role.id.to_s))
|
user_role: hash_including(data: hash_including(id: @normal_user_role.id.to_s))
|
||||||
|
@ -137,7 +137,7 @@ RSpec.describe "Api::V1::ProjectUserAssignmentsController", type: :request do
|
||||||
let(:request_body) do
|
let(:request_body) do
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
type: 'user_projects',
|
type: 'project_user_assignments',
|
||||||
attributes: {}
|
attributes: {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ RSpec.describe "Api::V1::ProjectUserAssignmentsController", type: :request do
|
||||||
let(:request_body) do
|
let(:request_body) do
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
type: 'user_projects',
|
type: 'project_user_assignments',
|
||||||
attributes: {
|
attributes: {
|
||||||
user_id: @another_user.id,
|
user_id: @another_user.id,
|
||||||
user_role_id: @normal_user_role.id
|
user_role_id: @normal_user_role.id
|
||||||
|
@ -206,7 +206,7 @@ RSpec.describe "Api::V1::ProjectUserAssignmentsController", type: :request do
|
||||||
let(:request_body) do
|
let(:request_body) do
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
type: 'user_projects',
|
type: 'project_user_assignments',
|
||||||
attributes: {
|
attributes: {
|
||||||
user_role_id: @technician_user_role.id
|
user_role_id: @technician_user_role.id
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ RSpec.describe "Api::V1::ProjectUserAssignmentsController", type: :request do
|
||||||
expect(json).to match(
|
expect(json).to match(
|
||||||
hash_including(
|
hash_including(
|
||||||
data: hash_including(
|
data: hash_including(
|
||||||
type: 'user_projects',
|
type: 'project_user_assignments',
|
||||||
relationships: hash_including(
|
relationships: hash_including(
|
||||||
user: hash_including(data: hash_including(id: @another_user.id.to_s)),
|
user: hash_including(data: hash_including(id: @another_user.id.to_s)),
|
||||||
user_role: hash_including(data: hash_including(id: @technician_user_role.id.to_s))
|
user_role: hash_including(data: hash_including(id: @technician_user_role.id.to_s))
|
||||||
|
@ -242,7 +242,7 @@ RSpec.describe "Api::V1::ProjectUserAssignmentsController", type: :request do
|
||||||
let(:request_body) do
|
let(:request_body) do
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
type: 'user_projects',
|
type: 'project_user_assignments',
|
||||||
attributes: {
|
attributes: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ RSpec.describe "Api::V1::ProjectUserAssignmentsController", type: :request do
|
||||||
let(:request_body) do
|
let(:request_body) do
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
type: 'user_projects',
|
type: 'project_user_assignments',
|
||||||
attributes: {
|
attributes: {
|
||||||
role: :technician
|
role: :technician
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue