mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 18:52:07 +08:00
Remove jsonapi_parameters gem, accept rails params in controller
This commit is contained in:
parent
7c1a0a9044
commit
df2b8ab3df
6 changed files with 14 additions and 46 deletions
1
Gemfile
1
Gemfile
|
@ -34,7 +34,6 @@ gem 'omniauth-rails_csrf_protection', '~> 0.1'
|
|||
gem 'active_model_serializers', '~> 0.10.7'
|
||||
gem 'json-jwt'
|
||||
gem 'jsonapi-renderer', '~> 0.2.2'
|
||||
gem 'jsonapi_parameters'
|
||||
gem 'jwt', '~> 1.5'
|
||||
gem 'kaminari'
|
||||
gem 'rack-attack'
|
||||
|
|
|
@ -307,9 +307,6 @@ GEM
|
|||
json_schema
|
||||
json_schema (0.20.7)
|
||||
jsonapi-renderer (0.2.2)
|
||||
jsonapi_parameters (2.2.0)
|
||||
actionpack (>= 4.1.8)
|
||||
activesupport (>= 4.1.8)
|
||||
jwt (1.5.6)
|
||||
kaminari (1.2.1)
|
||||
activesupport (>= 4.1.0)
|
||||
|
@ -651,7 +648,6 @@ DEPENDENCIES
|
|||
json-jwt
|
||||
json_matchers
|
||||
jsonapi-renderer (~> 0.2.2)
|
||||
jsonapi_parameters
|
||||
jwt (~> 1.5)
|
||||
kaminari
|
||||
listen (~> 3.0)
|
||||
|
|
|
@ -44,7 +44,7 @@ module Api
|
|||
def folder_params
|
||||
raise TypeError unless params.require(:data).require(:type) == 'project_folders'
|
||||
|
||||
params.from_jsonapi.require(:project_folder).permit(:name, :parent_folder_id)
|
||||
params.permit(data: { attributes: %i(name parent_folder_id) })[:data][:attributes]
|
||||
end
|
||||
|
||||
def update_folder_params
|
||||
|
|
|
@ -62,7 +62,7 @@ module Api
|
|||
def project_params
|
||||
raise TypeError unless params.require(:data).require(:type) == 'projects'
|
||||
|
||||
params.from_jsonapi.require(:project).permit(:name, :visibility, :archived, :project_folder_id)
|
||||
params.require(:data).require(:attributes).permit(:name, :visibility, :archived, :project_folder_id)
|
||||
end
|
||||
|
||||
def load_project_for_managing
|
||||
|
|
|
@ -67,15 +67,8 @@ RSpec.describe 'Api::V1::ProjectFoldersController', type: :request do
|
|||
data: {
|
||||
type: 'project_folders',
|
||||
attributes: {
|
||||
name: project_folder_name
|
||||
},
|
||||
relationships: {
|
||||
parent_folder: {
|
||||
data: {
|
||||
type: 'project_folders',
|
||||
id: parent_folder_id
|
||||
}
|
||||
}
|
||||
name: project_folder_name,
|
||||
parent_folder_id: parent_folder_id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,15 +131,8 @@ RSpec.describe 'Api::V1::ProjectFoldersController', type: :request do
|
|||
id: project_folder.id,
|
||||
type: 'project_folders',
|
||||
attributes: {
|
||||
name: project_folder_name
|
||||
},
|
||||
relationships: {
|
||||
parent_folder: {
|
||||
data: {
|
||||
type: 'project_folders',
|
||||
id: parent_folder_id
|
||||
}
|
||||
}
|
||||
name: project_folder_name,
|
||||
parent_folder_id: parent_folder_id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,27 +148,20 @@ RSpec.describe 'Api::V1::ProjectsController', type: :request do
|
|||
)
|
||||
end
|
||||
|
||||
context 'when includes folder relation' do
|
||||
context 'when includes project_folder relation' do
|
||||
let(:request_body) do
|
||||
{
|
||||
data: {
|
||||
type: 'projects',
|
||||
attributes: {
|
||||
name: 'Project name',
|
||||
visibility: 'hidden'
|
||||
},
|
||||
relationships: {
|
||||
project_folder: {
|
||||
data: {
|
||||
type: 'project_folders',
|
||||
id: folder.id
|
||||
}
|
||||
}
|
||||
visibility: 'hidden',
|
||||
project_folder_id: project_folder.id
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
let(:folder) { create :project_folder, team: @teams.first }
|
||||
let(:project_folder) { create :project_folder, team: @teams.first }
|
||||
|
||||
it 'renders 201' do
|
||||
action
|
||||
|
@ -248,24 +241,18 @@ RSpec.describe 'Api::V1::ProjectsController', type: :request do
|
|||
)
|
||||
end
|
||||
|
||||
context 'when includes folder relation' do
|
||||
context 'when includes project_folder relation' do
|
||||
let(:request_body) do
|
||||
{
|
||||
data: {
|
||||
type: 'projects',
|
||||
attributes: {},
|
||||
relationships: {
|
||||
project_folder: {
|
||||
data: {
|
||||
type: 'project_folders',
|
||||
id: folder.id
|
||||
}
|
||||
}
|
||||
attributes: {
|
||||
project_folder_id: project_folder.id
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
let(:folder) { create :project_folder, team: @teams.first }
|
||||
let(:project_folder) { create :project_folder, team: @teams.first }
|
||||
|
||||
it 'renders 201' do
|
||||
action
|
||||
|
|
Loading…
Reference in a new issue