Fix failing tests [ok_SCI_4197]

This commit is contained in:
Oleksii Kriuchykhin 2020-01-10 11:09:47 +01:00
parent ad5a5f3ebf
commit 4799e6a1eb
7 changed files with 30 additions and 22 deletions

View file

@ -13,94 +13,94 @@ class RepositoryCell < ApplicationRecord
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryTextValue' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
belongs_to :repository_number_value,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryNumberValue' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
belongs_to :repository_date_value,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryDateTimeValueBase' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
belongs_to :repository_list_value,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryListValue' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
belongs_to :repository_asset_value,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryAssetValue' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
belongs_to :repository_status_value,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryStatusValue' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
belongs_to :repository_checklist_value,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryChecklistValue' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
belongs_to :repository_date_time_value_base,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryDateTimeValueBase' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
belongs_to :repository_date_time_value,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryDateTimeValueBase' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
belongs_to :repository_time_value,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryDateTimeValueBase' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
belongs_to :repository_date_time_range_value_base,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryDateTimeRangeValueBase' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
belongs_to :repository_date_time_range_value,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryDateTimeRangeValueBase' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
belongs_to :repository_date_range_value,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryDateTimeRangeValueBase' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
belongs_to :repository_time_range_value,
(lambda do
includes(:repository_cell)
.where(repository_cells: { value_type: 'RepositoryDateTimeRangeValueBase' })
end),
optional: true, foreign_key: :value_id, inverse_of: :repository_cell
optional: true, foreign_key: :value_id
validates :repository_column,
inclusion: { in: (lambda do |cell|

View file

@ -8,9 +8,10 @@ class RepositoryChecklistValue < ApplicationRecord
has_one :repository_cell, as: :value, dependent: :destroy, inverse_of: :value
has_many :repository_cell_values_checklist_items, dependent: :destroy
has_many :repository_checklist_items, through: :repository_cell_values_checklist_items
accepts_nested_attributes_for :repository_cell
validates :repository_cell, presence: true
SORTABLE_COLUMN_NAME = 'repository_checklist_items.data'
SORTABLE_VALUE_INCLUDE = { repository_checklist_value: :repository_checklist_items }.freeze

View file

@ -9,7 +9,7 @@ class RepositoryStatusValue < ApplicationRecord
has_one :repository_cell, as: :value, dependent: :destroy, inverse_of: :value
accepts_nested_attributes_for :repository_cell
validates :repository_status_item, presence: true
validates :repository_cell, :repository_status_item, presence: true
SORTABLE_COLUMN_NAME = 'repository_status_items.status'
SORTABLE_VALUE_INCLUDE = { repository_status_value: :repository_status_item }.freeze

View file

@ -7,9 +7,7 @@ class RepositoryTextValue < ApplicationRecord
accepts_nested_attributes_for :repository_cell
validates :repository_cell, presence: true
validates :data,
presence: true,
length: { maximum: Constants::TEXT_MAX_LENGTH }
validates :data, presence: true, length: { maximum: Constants::TEXT_MAX_LENGTH }
SORTABLE_COLUMN_NAME = 'repository_text_values.data'
SORTABLE_VALUE_INCLUDE = :repository_text_value

View file

@ -75,9 +75,9 @@ FactoryBot.define do
end
trait :checkbox_value do
repository_column { create :repository_column, :date_time_range_type, repository: repository_row.repository }
repository_column { create :repository_column, :checklist_type, repository: repository_row.repository }
after(:build) do |repository_cell|
repository_cell.value ||= build(:repository_checkbox_value, repository_cell: repository_cell)
repository_cell.value ||= build(:repository_checklist_value, repository_cell: repository_cell)
end
end
end

View file

@ -5,5 +5,10 @@ FactoryBot.define do
created_by { create :user }
last_modified_by { created_by }
repository_checklist_items { [] }
after(:build) do |repository_checklist_value|
repository_checklist_value.repository_cell ||= build(:repository_cell,
:checkbox_value,
repository_checklist_value: repository_checklist_value)
end
end
end

View file

@ -4,7 +4,11 @@ FactoryBot.define do
factory :repository_status_value do
created_by { create :user }
last_modified_by { created_by }
repository_status_item
after(:build) do |repository_status_value|
repository_status_value.repository_cell ||= build(:repository_cell,
:status_value,
repository_status_value: repository_status_value)
end
end
end