Add timestamps to API serializers, allow inclusion of comments [SCI-5983]

This commit is contained in:
Oleksii Kriuchykhin 2021-08-18 10:00:01 +02:00
parent 6e1d51e2f3
commit 33d37d048e
63 changed files with 500 additions and 292 deletions

View file

@ -7,8 +7,8 @@ module Api
class IDMismatchError < StandardError; end
class IncludeNotSupportedError < StandardError; end
class PermissionError < StandardError
attr_reader :klass
attr_reader :mode
attr_reader :klass, :mode
def initialize(klass, mode)
@klass = klass
@mode = mode

View file

@ -16,11 +16,11 @@ module Api
.page(params.dig(:page, :number))
.per(params.dig(:page, :size))
render jsonapi: projects, each_serializer: ProjectSerializer
render jsonapi: projects, each_serializer: ProjectSerializer, include: include_params
end
def show
render jsonapi: @project, serializer: ProjectSerializer
render jsonapi: @project, serializer: ProjectSerializer, include: include_params
end
def create
@ -64,6 +64,10 @@ module Api
params.require(:data).require(:attributes).permit(:name, :visibility, :archived, :project_folder_id)
end
def permitted_includes
%w(comments)
end
def load_project_for_managing
@project = @team.projects.find(params.require(:id))
raise PermissionError.new(Project, :manage) unless can_manage_project?(@project)

View file

@ -12,7 +12,7 @@ module Api
.page(params.dig(:page, :number))
.per(params.dig(:page, :size))
render jsonapi: results, each_serializer: ResultSerializer,
include: %i(text table file)
include: (%i(text table file) << include_params).flatten.compact
end
def create
@ -43,7 +43,7 @@ module Api
def show
render jsonapi: @result, serializer: ResultSerializer,
include: %i(text table file)
include: (%i(text table file) << include_params).flatten.compact
end
private
@ -185,6 +185,10 @@ module Api
prms
end
def permitted_includes
%w(comments)
end
def convert_old_tiny_mce_format(text)
text.scan(/\[~tiny_mce_id:(\w+)\]/).flatten.each do |token|
old_format = /\[~tiny_mce_id:#{token}\]/

View file

@ -20,11 +20,17 @@ module Api
.page(params.dig(:page, :number))
.per(params.dig(:page, :size))
render jsonapi: tasks, each_serializer: TaskSerializer, rte_rendering: render_rte?, team: @team
render jsonapi: tasks, each_serializer: TaskSerializer,
include: include_params,
rte_rendering: render_rte?,
team: @team
end
def show
render jsonapi: @task, serializer: TaskSerializer, rte_rendering: render_rte?, team: @team
render jsonapi: @task, serializer: TaskSerializer,
include: include_params,
rte_rendering: render_rte?,
team: @team
end
def create
@ -69,6 +75,10 @@ module Api
params.require(:data).require(:attributes).permit(%i(name x y description my_module_status_id))
end
def permitted_includes
%w(comments)
end
def load_task_for_managing
@task = @experiment.my_modules.find(params.require(:id))
raise PermissionError.new(MyModule, :manage) unless can_manage_module?(@task)

View file

@ -19,6 +19,8 @@ module Api
belongs_to :subject, polymorphic: true
belongs_to :owner, key: :user, serializer: UserSerializer
include TimestampableModel
def message
if object.old_activity?
object.message

View file

@ -9,6 +9,8 @@ module Api
attributes :id, :file_name, :file_size, :file_type, :file_url
belongs_to :step, serializer: StepSerializer
include TimestampableModel
def file_type
object.content_type
end

View file

@ -5,6 +5,8 @@ module Api
class ChecklistItemSerializer < ActiveModel::Serializer
type :checklist_items
attributes :id, :text, :checked, :position
include TimestampableModel
end
end
end

View file

@ -6,6 +6,8 @@ module Api
type :checklists
attributes :id, :name
has_many :checklist_items, serializer: ChecklistItemSerializer
include TimestampableModel
end
end
end

View file

@ -26,6 +26,8 @@ module Api
serializer: ResultSerializer,
if: -> { object.class == ResultComment &&
!instance_options[:hide_result] }
include TimestampableModel
end
end
end

View file

@ -11,6 +11,8 @@ module Api
belongs_to :to, key: :output_task,
serializer: TaskSerializer,
class_name: 'MyModule'
include TimestampableModel
end
end
end

View file

@ -5,6 +5,8 @@ module Api
class ExperimentSerializer < ActiveModel::Serializer
type :experiments
attributes :id, :name, :description, :archived
include TimestampableModel
end
end
end

View file

@ -7,6 +7,8 @@ module Api
attributes :id, :value_type, :value
attribute :repository_column_id, key: :column_id
include TimestampableModel
def value
ActiveModelSerializers::SerializableResource.new(
object.value,

View file

@ -5,6 +5,8 @@ module Api
class InventoryChecklistItemSerializer < ActiveModel::Serializer
type :inventory_checklist_items
attributes :id, :data
include TimestampableModel
end
end
end

View file

@ -30,6 +30,8 @@ module Api
!instance_options[:hide_list_items]
end)
include TimestampableModel
def data_type
Extends::API_REPOSITORY_DATA_TYPE_MAPPINGS[object.data_type]
end

View file

@ -13,6 +13,8 @@ module Api
serializer: InventorySerializer,
class_name: 'Repository',
if: -> { instance_options[:show_repository] }
include TimestampableModel
end
end
end

View file

@ -5,6 +5,8 @@ module Api
class InventoryListItemSerializer < ActiveModel::Serializer
type :inventory_list_items
attribute :data
include TimestampableModel
end
end
end

View file

@ -6,6 +6,8 @@ module Api
type :inventories
attributes :id, :name
belongs_to :created_by, serializer: UserSerializer
include TimestampableModel
end
end
end

View file

@ -5,6 +5,8 @@ module Api
class InventoryStatusItemSerializer < ActiveModel::Serializer
type :inventory_status_items
attributes :status, :icon
include TimestampableModel
end
end
end

View file

@ -10,6 +10,8 @@ module Api
belongs_to :parent_folder, serializer: ProjectFolderSerializer
has_many :projects, serializer: ProjectSerializer
has_many :project_folders, serializer: ProjectFolderSerializer
include TimestampableModel
end
end
end

View file

@ -7,6 +7,9 @@ module Api
attributes :name, :visibility, :start_date, :archived
belongs_to :project_folder, serializer: ProjectFolderSerializer
has_many :project_comments, key: :comments, serializer: CommentSerializer
include TimestampableModel
def start_date
object.created_at

View file

@ -5,6 +5,8 @@ module Api
class ProtocolKeywordSerializer < ActiveModel::Serializer
type :protocol_keywords
attributes :id, :name
include TimestampableModel
end
end
end

View file

@ -17,6 +17,8 @@ module Api
has_many :steps, serializer: StepSerializer, if: -> { object.steps.any? }
belongs_to :parent, serializer: ProtocolSerializer, if: -> { object.parent.present? }
include TimestampableModel
def description
if instance_options[:rte_rendering]
custom_auto_link(object.tinymce_render(:description),

View file

@ -15,6 +15,8 @@ module Api
belongs_to :project, serializer: ProjectSerializer,
unless: -> { instance_options[:hide_project] }
include TimestampableModel
def pdf_file_size
object.pdf_file.blob.byte_size
end

View file

@ -5,6 +5,8 @@ module Api
class RepositoryAssetValueSerializer < ActiveModel::Serializer
attributes :file_id, :file_name, :file_size, :url
include TimestampableModel
def file_id
object.asset&.id
end

View file

@ -9,6 +9,8 @@ module Api
attribute :inventory_checklist_item_names do
object.repository_checklist_items.pluck(:data)
end
include TimestampableModel
end
end
end

View file

@ -5,6 +5,8 @@ module Api
class RepositoryDateRangeValueSerializer < ActiveModel::Serializer
attribute :date_range
include TimestampableModel
def date_range
{
from: object.start_time.to_date,

View file

@ -5,6 +5,8 @@ module Api
class RepositoryDateTimeRangeValueSerializer < ActiveModel::Serializer
attribute :date_time_range
include TimestampableModel
def date_time_range
{
from: object.start_time,

View file

@ -5,6 +5,8 @@ module Api
class RepositoryDateTimeValueSerializer < ActiveModel::Serializer
attribute :date_time
include TimestampableModel
def date_time
object.data
end

View file

@ -5,6 +5,8 @@ module Api
class RepositoryDateValueSerializer < ActiveModel::Serializer
attribute :date
include TimestampableModel
def date
object.data.to_date
end

View file

@ -5,6 +5,8 @@ module Api
class RepositoryListValueSerializer < ActiveModel::Serializer
attribute :repository_list_item_id, key: :inventory_list_item_id
attribute :formatted, key: :inventory_list_item_name
include TimestampableModel
end
end
end

View file

@ -10,6 +10,8 @@ module Api
attribute :inventory_status_item_name do
object.repository_status_item.status
end
include TimestampableModel
end
end
end

View file

@ -4,6 +4,8 @@ module Api
module V1
class RepositoryTextValueSerializer < ActiveModel::Serializer
attribute :formatted, key: :text
include TimestampableModel
end
end
end

View file

@ -5,6 +5,8 @@ module Api
class RepositoryTimeRangeValueSerializer < ActiveModel::Serializer
attribute :time_range
include TimestampableModel
def time_range
{
from: object.start_time.strftime('%H:%M:%S.%3NZ'),

View file

@ -5,6 +5,8 @@ module Api
class RepositoryTimeValueSerializer < ActiveModel::Serializer
attribute :time
include TimestampableModel
def time
object.data.strftime('%H:%M:%S.%3NZ')
end

View file

@ -18,6 +18,9 @@ module Api
serializer: ResultAssetSerializer,
class_name: 'ResultAsset',
if: -> { object.is_asset }
has_many :result_comments, key: :comments, serializer: CommentSerializer
include TimestampableModel
end
end
end

View file

@ -8,7 +8,7 @@ module Api
include InputSanitizeHelper
type :steps
attributes :id, :name, :description, :created_at, :position, :completed
attributes :id, :name, :description, :position, :completed
attribute :completed_on, if: -> { object.completed? }
belongs_to :user, serializer: UserSerializer
belongs_to :protocol, serializer: ProtocolSerializer
@ -17,6 +17,8 @@ module Api
has_many :tables, serializer: TableSerializer
has_many :step_comments, key: :comments, serializer: CommentSerializer
include TimestampableModel
def description
if instance_options[:rte_rendering]
custom_auto_link(object.tinymce_render(:description),

View file

@ -6,6 +6,8 @@ module Api
type :tables
attributes :id, :name, :contents
include TimestampableModel
def contents
object.contents&.force_encoding(Encoding::UTF_8)
end

View file

@ -5,6 +5,8 @@ module Api
class TagSerializer < ActiveModel::Serializer
type :tags
attributes :id, :name, :color
include TimestampableModel
end
end
end

View file

@ -9,6 +9,8 @@ module Api
serializer: TaskSerializer,
class_name: 'MyModule',
unless: -> { object.my_modules.empty? }
include TimestampableModel
end
end
end

View file

@ -16,6 +16,9 @@ module Api
has_many :input_tasks, key: :inputs,
serializer: TaskSerializer,
class_name: 'MyModule'
has_many :task_comments, key: :comments, serializer: CommentSerializer
include TimestampableModel
def status_id
object.my_module_status_id

View file

@ -6,6 +6,8 @@ module Api
attributes :id, :name, :description, :space_taken
belongs_to :created_by, serializer: UserSerializer
include TimestampableModel
def space_taken
object.storage_used.to_i
end

View file

@ -2,6 +2,8 @@ module Api
module V1
class UserIdentitySerializer < ActiveModel::Serializer
attributes :provider, :uid
include TimestampableModel
end
end
end

View file

@ -5,8 +5,9 @@ module Api
class UserProjectSerializer < ActiveModel::Serializer
type :user_projects
attributes :id, :role
belongs_to :user, serializer: UserSerializer
include TimestampableModel
end
end
end

View file

@ -9,6 +9,8 @@ module Api
attribute :avatar_file_size, if: -> { object.avatar.attached? }
attribute :avatar_url, if: -> { object.avatar.attached? }
include TimestampableModel
def avatar_file_name
object.avatar.blob.filename
end

View file

@ -4,8 +4,9 @@ module Api
module V1
class WorkflowSerializer < ActiveModel::Serializer
type :workflows
attributes :id, :name, :description, :visibility, :team_id
include TimestampableModel
end
end
end

View file

@ -4,8 +4,9 @@ module Api
module V1
class WorkflowStatusSerializer < ActiveModel::Serializer
type :workflow_statuses
attributes :id, :name, :description, :color, :previous_status_id
include TimestampableModel
end
end
end

View file

@ -0,0 +1,9 @@
# frozen_string_literal: true
module TimestampableModel
extend ActiveSupport::Concern
included do
attributes :created_at, :updated_at
end
end

View file

@ -32,10 +32,12 @@ RSpec.describe "Api::V1::ExperimentsController", type: :request do
project_id: @valid_project), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_project.experiments,
each_serializer: Api::V1::ExperimentSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_project.experiments,
each_serializer: Api::V1::ExperimentSerializer)
.to_json
)['data']
)
end
@ -75,10 +77,12 @@ RSpec.describe "Api::V1::ExperimentsController", type: :request do
headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_project.experiments.first,
serializer: Api::V1::ExperimentSerializer)
.as_json[:data]
.to_json
)['data']
)
end

View file

@ -31,10 +31,11 @@ RSpec.describe 'Api::V1::InventoriesController', type: :request do
headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@teams.first.repositories,
each_serializer: Api::V1::InventorySerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@teams.first.repositories, each_serializer: Api::V1::InventorySerializer)
.to_json
)['data']
)
end
@ -72,10 +73,11 @@ RSpec.describe 'Api::V1::InventoriesController', type: :request do
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@teams.first.repositories.first,
serializer: Api::V1::InventorySerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@teams.first.repositories.first, serializer: Api::V1::InventorySerializer)
.to_json
)['data']
)
end
@ -127,10 +129,10 @@ RSpec.describe 'Api::V1::InventoriesController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(Repository.last,
serializer: Api::V1::InventorySerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource.new(Repository.last, serializer: Api::V1::InventorySerializer)
.to_json
)['data']
)
end
@ -222,7 +224,7 @@ RSpec.describe 'Api::V1::InventoriesController', type: :request do
headers: @valid_headers
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body.to_json).to match(updated_inventory.to_json)
expect(hash_body['data']['attributes']['name']).to match(updated_inventory[:data][:attributes][:name])
end
it 'When invalid request, inventory does not belong to team' do

View file

@ -413,10 +413,11 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.first,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.first, serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -459,10 +460,11 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last, serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -477,10 +479,11 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last, serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -495,10 +498,11 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last, serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -513,10 +517,11 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last, serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -531,10 +536,11 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last, serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -568,10 +574,11 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last, serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -586,10 +593,11 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last, serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -623,10 +631,11 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last, serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -641,10 +650,11 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last, serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -659,10 +669,11 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last, serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -677,10 +688,11 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryCell.last, serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -748,10 +760,12 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @text_column).first,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @text_column).first,
serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -766,10 +780,12 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @list_column).first,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @list_column).first,
serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -784,10 +800,12 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @status_column).first,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @status_column).first,
serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -803,10 +821,12 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @checklist_column).first,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @checklist_column).first,
serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -821,10 +841,12 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @file_column).first,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @file_column).first,
serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -859,10 +881,12 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @time_column).first,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @time_column).first,
serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -917,10 +941,12 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @time_range_column).first,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @time_range_column).first,
serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -935,10 +961,12 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @date_time_range_column).first,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @date_time_range_column).first,
serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -953,10 +981,12 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @number_column).first,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @number_column).first,
serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end
@ -971,10 +1001,12 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @number_column).first,
serializer: Api::V1::InventoryCellSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_item.repository_cells.where(repository_column: @number_column).first,
serializer: Api::V1::InventoryCellSerializer)
.to_json
)['data']
)
end

View file

@ -41,10 +41,12 @@ RSpec.describe 'Api::V1::InventoryChecklistItemsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@checklist_column.repository_checklist_items.limit(10),
each_serializer: Api::V1::InventoryChecklistItemSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@checklist_column.repository_checklist_items.limit(10),
each_serializer: Api::V1::InventoryChecklistItemSerializer)
.to_json
)['data']
)
end
@ -108,10 +110,12 @@ RSpec.describe 'Api::V1::InventoryChecklistItemsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@checklist_column.repository_checklist_items.first,
serializer: Api::V1::InventoryChecklistItemSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@checklist_column.repository_checklist_items.first,
serializer: Api::V1::InventoryChecklistItemSerializer)
.to_json
)['data']
)
end
@ -163,10 +167,11 @@ RSpec.describe 'Api::V1::InventoryChecklistItemsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryChecklistItem.last,
serializer: Api::V1::InventoryChecklistItemSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryChecklistItem.last, serializer: Api::V1::InventoryChecklistItemSerializer)
.to_json
)['data']
)
end
@ -273,10 +278,12 @@ RSpec.describe 'Api::V1::InventoryChecklistItemsController', type: :request do
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@checklist_column.repository_checklist_items.find(item_id),
serializer: Api::V1::InventoryChecklistItemSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@checklist_column.repository_checklist_items.find(item_id),
serializer: Api::V1::InventoryChecklistItemSerializer)
.to_json
)['data']
)
expect(@checklist_column.repository_checklist_items.find(item_id).data).to match('Updated')
end

View file

@ -40,11 +40,13 @@ RSpec.describe 'Api::V1::InventoryColumnsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_columns.limit(10),
each_serializer: Api::V1::InventoryColumnSerializer,
hide_list_items: true)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_columns.limit(10),
each_serializer: Api::V1::InventoryColumnSerializer,
hide_list_items: true)
.to_json
)['data']
)
end
@ -93,10 +95,11 @@ RSpec.describe 'Api::V1::InventoryColumnsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(text_column,
serializer: Api::V1::InventoryColumnSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(text_column, serializer: Api::V1::InventoryColumnSerializer)
.to_json
)['data']
)
expect(hash_body[:data]).not_to include('relationships')
end
@ -111,18 +114,21 @@ RSpec.describe 'Api::V1::InventoryColumnsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(list_column,
serializer: Api::V1::InventoryColumnSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(list_column, serializer: Api::V1::InventoryColumnSerializer)
.to_json
)['data']
)
expect(hash_body[:data]).to include('relationships')
expect(hash_body[:included]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_columns.limit(10),
each_serializer: Api::V1::InventoryColumnSerializer,
include: :inventory_list_items)
.as_json[:included]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_columns.limit(10),
each_serializer: Api::V1::InventoryColumnSerializer,
include: :inventory_list_items)
.to_json
)['included']
)
end
@ -136,18 +142,21 @@ RSpec.describe 'Api::V1::InventoryColumnsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(status_column,
serializer: Api::V1::InventoryColumnSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(status_column, serializer: Api::V1::InventoryColumnSerializer)
.to_json
)['data']
)
expect(hash_body[:data]).to include('relationships')
expect(hash_body[:included]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_columns.limit(10),
each_serializer: Api::V1::InventoryColumnSerializer,
include: :inventory_status_items)
.as_json[:included]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_columns.limit(10),
each_serializer: Api::V1::InventoryColumnSerializer,
include: :inventory_status_items)
.to_json
)['included']
)
end
@ -161,10 +170,11 @@ RSpec.describe 'Api::V1::InventoryColumnsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(file_column,
serializer: Api::V1::InventoryColumnSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(file_column, serializer: Api::V1::InventoryColumnSerializer)
.to_json
)['data']
)
expect(hash_body[:data]).not_to include('relationships')
end
@ -221,11 +231,11 @@ RSpec.describe 'Api::V1::InventoryColumnsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryColumn.last,
serializer: Api::V1::InventoryColumnSerializer,
include: :inventory_cells)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryColumn.last, serializer: Api::V1::InventoryColumnSerializer, include: :inventory_cells)
.to_json
)['data']
)
end
@ -397,7 +407,7 @@ RSpec.describe 'Api::V1::InventoryColumnsController', type: :request do
headers: @valid_headers
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body.to_json).to match(returned_inventory_column.to_json)
expect(hash_body['data']['attributes']['name']).to match(returned_inventory_column[:data][:attributes][:name])
end
it 'Invalid request, wrong team' do

View file

@ -68,11 +68,13 @@ RSpec.describe 'Api::V1::InventoryItemsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_rows.limit(10),
each_serializer: Api::V1::InventoryItemSerializer,
include: :inventory_cells)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_rows.limit(10),
each_serializer: Api::V1::InventoryItemSerializer,
include: :inventory_cells)
.to_json
)['data']
)
expect(hash_body).not_to include('included')
end
@ -86,18 +88,22 @@ RSpec.describe 'Api::V1::InventoryItemsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_rows.limit(10),
each_serializer: Api::V1::InventoryItemSerializer,
include: :inventory_cells)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_rows.limit(10),
each_serializer: Api::V1::InventoryItemSerializer,
include: :inventory_cells)
.to_json
)['data']
)
expect(hash_body[:included]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_rows.limit(10),
each_serializer: Api::V1::InventoryItemSerializer,
include: :inventory_cells)
.as_json[:included]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_rows.limit(10),
each_serializer: Api::V1::InventoryItemSerializer,
include: :inventory_cells)
.to_json
)['included']
)
end
@ -109,11 +115,13 @@ RSpec.describe 'Api::V1::InventoryItemsController', type: :request do
), params: { page: { size: 100 } }, headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_rows.limit(100),
each_serializer: Api::V1::InventoryItemSerializer,
include: :inventory_cells)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_inventory.repository_rows.limit(100),
each_serializer: Api::V1::InventoryItemSerializer,
include: :inventory_cells)
.to_json
)['data']
)
expect(hash_body).not_to include('included')
end
@ -227,18 +235,18 @@ RSpec.describe 'Api::V1::InventoryItemsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryRow.last,
serializer: Api::V1::InventoryItemSerializer,
include: :inventory_cells)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryRow.last, serializer: Api::V1::InventoryItemSerializer, include: :inventory_cells)
.to_json
)['data']
)
expect(hash_body[:included]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryRow.last,
serializer: Api::V1::InventoryItemSerializer,
include: :inventory_cells)
.as_json[:included]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryRow.last, serializer: Api::V1::InventoryItemSerializer, include: :inventory_cells)
.to_json
)['included']
)
end
@ -288,8 +296,8 @@ RSpec.describe 'Api::V1::InventoryItemsController', type: :request do
it 'Response with correctly updated inventory item for name field' do
hash_body = nil
updated_inventory_item = @inventory_item.as_json[:data]
updated_inventory_item[:attributes][:name] = Faker::Name.unique.name
updated_inventory_item = JSON.parse(@inventory_item.to_json)['data']
updated_inventory_item['attributes']['name'] = Faker::Name.unique.name
patch api_v1_team_inventory_item_path(
id: RepositoryRow.last.id,
team_id: @teams.first.id,
@ -298,7 +306,7 @@ RSpec.describe 'Api::V1::InventoryItemsController', type: :request do
headers: @valid_headers
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data].to_json).to match(updated_inventory_item.to_json)
expect(hash_body['data']['attributes']['name']).to match(updated_inventory_item['attributes']['name'])
end
end
end

View file

@ -41,10 +41,11 @@ RSpec.describe 'Api::V1::InventoryListItemsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@list_column.repository_list_items.limit(10),
each_serializer: Api::V1::InventoryListItemSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@list_column.repository_list_items.limit(10), each_serializer: Api::V1::InventoryListItemSerializer)
.to_json
)['data']
)
end
@ -108,10 +109,11 @@ RSpec.describe 'Api::V1::InventoryListItemsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@list_column.repository_list_items.first,
serializer: Api::V1::InventoryListItemSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@list_column.repository_list_items.first, serializer: Api::V1::InventoryListItemSerializer)
.to_json
)['data']
)
end
@ -163,10 +165,11 @@ RSpec.describe 'Api::V1::InventoryListItemsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(RepositoryListItem.last,
serializer: Api::V1::InventoryListItemSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(RepositoryListItem.last, serializer: Api::V1::InventoryListItemSerializer)
.to_json
)['data']
)
end
@ -273,10 +276,11 @@ RSpec.describe 'Api::V1::InventoryListItemsController', type: :request do
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@list_column.repository_list_items.find(item_id),
serializer: Api::V1::InventoryListItemSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@list_column.repository_list_items.find(item_id), serializer: Api::V1::InventoryListItemSerializer)
.to_json
)['data']
)
expect(@list_column.repository_list_items.find(item_id).data).to match('Updated')
end

View file

@ -69,9 +69,11 @@ RSpec.describe 'Api::V1::ResultsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_task.results, each_serializer: Api::V1::ResultSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_task.results, each_serializer: Api::V1::ResultSerializer)
.to_json
)['data']
)
end
@ -153,16 +155,18 @@ RSpec.describe 'Api::V1::ResultsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(Result.last,
serializer: Api::V1::ResultSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(Result.last, serializer: Api::V1::ResultSerializer)
.to_json
)['data']
)
expect(hash_body[:included]).to match(
ActiveModelSerializers::SerializableResource
.new(Result.last, serializer: Api::V1::ResultSerializer,
include: :text)
.as_json[:included]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(Result.last, serializer: Api::V1::ResultSerializer, include: :text)
.to_json
)['included']
)
end
@ -177,15 +181,18 @@ RSpec.describe 'Api::V1::ResultsController', type: :request do
expect(response).to have_http_status 201
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(Result.last, serializer: Api::V1::ResultSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(Result.last, serializer: Api::V1::ResultSerializer)
.to_json
)['data']
)
expect(hash_body[:included]).to match(
ActiveModelSerializers::SerializableResource
.new(Result.last, serializer: Api::V1::ResultSerializer,
include: :text)
.as_json[:included]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(Result.last, serializer: Api::V1::ResultSerializer, include: :text)
.to_json
)['included']
)
expect(ResultText.last.text).to include "data-mce-token=\"#{Base62.encode(TinyMceAsset.last.id)}\""
end
@ -343,9 +350,11 @@ RSpec.describe 'Api::V1::ResultsController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@valid_task.results.first, serializer: Api::V1::ResultSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@valid_task.results.first, serializer: Api::V1::ResultSerializer)
.to_json
)['data']
)
end

View file

@ -18,9 +18,11 @@ RSpec.describe 'Api::V1::TeamsController', type: :request do
get api_v1_teams_path, headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@user.teams, each_serializer: Api::V1::TeamSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@user.teams, each_serializer: Api::V1::TeamSerializer)
.to_json
)['data']
)
end
end
@ -31,9 +33,11 @@ RSpec.describe 'Api::V1::TeamsController', type: :request do
get api_v1_team_path(id: @teams.second.id), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@teams.second, serializer: Api::V1::TeamSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@teams.second, serializer: Api::V1::TeamSerializer)
.to_json
)['data']
)
end

View file

@ -19,10 +19,11 @@ RSpec.describe 'Api::V1::UsersIdentitiesController', type: :request do
headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@user1.user_identities,
each_serializer: Api::V1::UserIdentitySerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@user1.user_identities, each_serializer: Api::V1::UserIdentitySerializer)
.to_json
)['data']
)
end
@ -57,10 +58,11 @@ RSpec.describe 'Api::V1::UsersIdentitiesController', type: :request do
headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@user1.user_identities.order(:id).last,
serializer: Api::V1::UserIdentitySerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@user1.user_identities.order(:id).last, serializer: Api::V1::UserIdentitySerializer)
.to_json
)['data']
)
end
end
@ -73,10 +75,11 @@ RSpec.describe 'Api::V1::UsersIdentitiesController', type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@user1.user_identities.order(:id).last,
serializer: Api::V1::UserIdentitySerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@user1.user_identities.order(:id).last, serializer: Api::V1::UserIdentitySerializer)
.to_json
)['data']
)
end
end
@ -94,10 +97,11 @@ RSpec.describe 'Api::V1::UsersIdentitiesController', type: :request do
headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@user1.user_identities.order(:id).last,
serializer: Api::V1::UserIdentitySerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@user1.user_identities.order(:id).last, serializer: Api::V1::UserIdentitySerializer)
.to_json
)['data']
)
end
end

View file

@ -24,9 +24,11 @@ RSpec.describe "Api::V1::UserProjectsController", type: :request do
headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@own_project.user_projects, each_serializer: Api::V1::UserProjectSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@own_project.user_projects, each_serializer: Api::V1::UserProjectSerializer)
.to_json
)['data']
)
end
@ -56,9 +58,11 @@ RSpec.describe "Api::V1::UserProjectsController", type: :request do
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@own_project.user_projects.first, serializer: Api::V1::UserProjectSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@own_project.user_projects.first, serializer: Api::V1::UserProjectSerializer)
.to_json
)['data']
)
end

View file

@ -24,9 +24,11 @@ RSpec.describe 'Api::V1::UsersController', type: :request do
get api_v1_user_path(id: @user2.id), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(@user2, serializer: Api::V1::UserSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@user2, serializer: Api::V1::UserSerializer)
.to_json
)['data']
)
end

View file

@ -18,10 +18,11 @@ RSpec.describe 'Api::V1::WrokflowStatusesController', type: :request do
get api_v1_workflow_workflow_statuses_path(workflow_id: MyModuleStatusFlow.first.id), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(MyModuleStatusFlow.first.my_module_statuses,
each_serializer: Api::V1::WorkflowStatusSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(MyModuleStatusFlow.first.my_module_statuses, each_serializer: Api::V1::WorkflowStatusSerializer)
.to_json
)['data']
)
end
end

View file

@ -18,10 +18,11 @@ RSpec.describe 'Api::V1::WrokflowsController', type: :request do
get api_v1_workflows_path, headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(MyModuleStatusFlow.all,
each_serializer: Api::V1::WorkflowSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(MyModuleStatusFlow.all, each_serializer: Api::V1::WorkflowSerializer)
.to_json
)['data']
)
end
end
@ -32,10 +33,11 @@ RSpec.describe 'Api::V1::WrokflowsController', type: :request do
get api_v1_workflow_path(id: MyModuleStatusFlow.all.first), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
ActiveModelSerializers::SerializableResource
.new(MyModuleStatusFlow.all.first,
serializer: Api::V1::WorkflowSerializer)
.as_json[:data]
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(MyModuleStatusFlow.all.first, serializer: Api::V1::WorkflowSerializer)
.to_json
)['data']
)
end

View file

@ -13,6 +13,12 @@
"properties": {
"name": {
"type": "string"
},
"created_at": {
"type": "string"
},
"updated_at": {
"type": "string"
}
},
"additionalProperties": false,
@ -43,7 +49,3 @@
"additionalProperties": false,
"required": ["id", "type", "attributes"]
}

View file

@ -16,6 +16,12 @@
},
"status": {
"type": "string"
},
"created_at": {
"type": "string"
},
"updated_at": {
"type": "string"
}
},
"additionalProperties": false,
@ -28,7 +34,3 @@
"additionalProperties": false,
"required": ["id", "type", "attributes"]
}