mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-09 16:01:30 +08:00
Merge pull request #2971 from okriuchykhin/ok_SCI_5238
Improve limit check for repository list and checklist items [SCI-5238]
This commit is contained in:
commit
7b17d9d54d
6 changed files with 13 additions and 5 deletions
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RepositoryChecklistItem < ApplicationRecord
|
||||
belongs_to :repository_column
|
||||
belongs_to :repository_column, inverse_of: :repository_checklist_items
|
||||
belongs_to :created_by, foreign_key: 'created_by_id', class_name: 'User',
|
||||
inverse_of: :created_repository_checklist_types
|
||||
belongs_to :last_modified_by, foreign_key: 'last_modified_by_id', class_name: 'User',
|
||||
|
|
@ -18,7 +18,7 @@ class RepositoryChecklistItem < ApplicationRecord
|
|||
|
||||
def validate_per_column_limit
|
||||
if repository_column &&
|
||||
repository_column.repository_checklist_items.count > Constants::REPOSITORY_CHECKLIST_ITEMS_PER_COLUMN
|
||||
repository_column.repository_checklist_items.size > Constants::REPOSITORY_CHECKLIST_ITEMS_PER_COLUMN
|
||||
errors.add(:base, :per_column_limit)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class RepositoryListItem < ApplicationRecord
|
|||
|
||||
def validate_per_column_limit
|
||||
if repository_column &&
|
||||
repository_column.repository_list_items.count > Constants::REPOSITORY_LIST_ITEMS_PER_COLUMN
|
||||
repository_column.repository_list_items.size > Constants::REPOSITORY_LIST_ITEMS_PER_COLUMN
|
||||
errors.add(:base, :per_column_limit)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class RepositoryListValue < ApplicationRecord
|
|||
value.repository_list_item = value.repository_cell
|
||||
.repository_column
|
||||
.repository_list_items
|
||||
.find(payload)
|
||||
.find_by(id: payload)
|
||||
value
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,5 +6,9 @@ FactoryBot.define do
|
|||
repository_column { create :repository_column, :checklist_type }
|
||||
created_by { create :user }
|
||||
last_modified_by { created_by }
|
||||
|
||||
after(:create) do |item|
|
||||
item.repository_column.reload
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,5 +6,9 @@ FactoryBot.define do
|
|||
repository_column { create :repository_column, :list_type }
|
||||
created_by { create :user }
|
||||
last_modified_by { created_by }
|
||||
|
||||
after(:create) do |item|
|
||||
item.repository_column.reload
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ RSpec.describe RepositoryListValue, type: :model do
|
|||
describe 'self.new_with_payload' do
|
||||
let(:user) { create :user }
|
||||
let(:column) { create :repository_column }
|
||||
let(:cell) { build :repository_cell, repository_column: column }
|
||||
let(:list_item) { create :repository_list_item, repository_column: column }
|
||||
let(:cell) { build :repository_cell, repository_column: column }
|
||||
let(:attributes) do
|
||||
{
|
||||
repository_cell: cell,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue