mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-26 09:43:29 +08:00
Fix failing tests [SCI-4516]
This commit is contained in:
parent
3a67c99982
commit
837437309e
38 changed files with 89 additions and 171 deletions
|
@ -67,8 +67,7 @@ module Api
|
|||
params.require(:data).require(:attributes)
|
||||
params.permit(data: { attributes: %i(data) })[:data].merge(
|
||||
created_by: @current_user,
|
||||
last_modified_by: @current_user,
|
||||
repository: @inventory
|
||||
last_modified_by: @current_user
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -71,8 +71,7 @@ module Api
|
|||
params.require(:data).require(:attributes)
|
||||
params.permit(data: { attributes: %i(data) })[:data].merge(
|
||||
created_by: @current_user,
|
||||
last_modified_by: @current_user,
|
||||
repository: @inventory
|
||||
last_modified_by: @current_user
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -61,8 +61,7 @@ module Api
|
|||
params.require(:data).require(:attributes)
|
||||
params.permit(data: { attributes: %i(status icon) })[:data].merge(
|
||||
created_by: @current_user,
|
||||
last_modified_by: @current_user,
|
||||
repository: @inventory
|
||||
last_modified_by: @current_user
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -40,21 +40,12 @@ class MyModule < ApplicationRecord
|
|||
has_many :my_module_tags, inverse_of: :my_module, dependent: :destroy
|
||||
has_many :tags, through: :my_module_tags
|
||||
has_many :task_comments, foreign_key: :associated_id, dependent: :destroy
|
||||
has_many :inputs,
|
||||
class_name: 'Connection',
|
||||
foreign_key: 'input_id',
|
||||
inverse_of: :to,
|
||||
dependent: :destroy
|
||||
has_many :outputs,
|
||||
class_name: 'Connection',
|
||||
foreign_key: 'output_id',
|
||||
inverse_of: :from,
|
||||
dependent: :destroy
|
||||
has_many :my_modules, through: :outputs, source: :to
|
||||
has_many :my_module_antecessors,
|
||||
through: :inputs,
|
||||
source: :from,
|
||||
class_name: 'MyModule'
|
||||
|
||||
has_many :inputs, class_name: 'Connection', foreign_key: 'input_id', inverse_of: :to, dependent: :destroy
|
||||
has_many :outputs, class_name: 'Connection', foreign_key: 'output_id', inverse_of: :from, dependent: :destroy
|
||||
has_many :my_modules, through: :outputs, source: :to, class_name: 'MyModule'
|
||||
has_many :my_module_antecessors, through: :inputs, source: :from, class_name: 'MyModule'
|
||||
|
||||
has_many :sample_my_modules,
|
||||
inverse_of: :my_module,
|
||||
dependent: :destroy
|
||||
|
|
|
@ -83,8 +83,7 @@ class RepositoryChecklistValue < ApplicationRecord
|
|||
if checklist_item.blank?
|
||||
checklist_item = column.repository_checklist_items.new(data: text,
|
||||
created_by: value.created_by,
|
||||
last_modified_by: value.last_modified_by,
|
||||
repository: column.repository)
|
||||
last_modified_by: value.last_modified_by)
|
||||
|
||||
return nil unless checklist_item.save
|
||||
end
|
||||
|
|
|
@ -73,8 +73,7 @@ class RepositoryListValue < ApplicationRecord
|
|||
if list_item.blank?
|
||||
list_item = column.repository_list_items.new(data: text,
|
||||
created_by: value.created_by,
|
||||
last_modified_by: value.last_modified_by,
|
||||
repository: column.repository)
|
||||
last_modified_by: value.last_modified_by)
|
||||
|
||||
return nil unless list_item.save
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RepositoryStatusItem < ApplicationRecord
|
||||
validates :repository, :repository_column, :icon, presence: true
|
||||
validates :repository_column, :icon, presence: true
|
||||
validates :status, presence: true, length: { minimum: Constants::NAME_MIN_LENGTH,
|
||||
maximum: Constants::NAME_MAX_LENGTH }
|
||||
belongs_to :repository_column
|
||||
|
|
|
@ -69,8 +69,7 @@ class RepositoryStatusValue < ApplicationRecord
|
|||
status_item = column.repository_status_items.new(icon: icon,
|
||||
status: status,
|
||||
created_by: value.created_by,
|
||||
last_modified_by: value.last_modified_by,
|
||||
repository: column.repository)
|
||||
last_modified_by: value.last_modified_by)
|
||||
|
||||
return nil unless status_item.save
|
||||
end
|
||||
|
|
|
@ -26,15 +26,15 @@ module RepositoryColumns
|
|||
|
||||
def column_attributes
|
||||
@params[:repository_status_items_attributes]&.map do |m|
|
||||
m.merge!(repository_id: @repository.id, created_by_id: @user.id, last_modified_by_id: @user.id)
|
||||
m.merge!(created_by_id: @user.id, last_modified_by_id: @user.id)
|
||||
end
|
||||
|
||||
@params[:repository_list_items_attributes]&.map do |m|
|
||||
m.merge!(repository_id: @repository.id, created_by_id: @user.id, last_modified_by_id: @user.id)
|
||||
m.merge!(created_by_id: @user.id, last_modified_by_id: @user.id)
|
||||
end
|
||||
|
||||
@params[:repository_checklist_items_attributes]&.map do |m|
|
||||
m.merge!(repository_id: @repository.id, created_by_id: @user.id, last_modified_by_id: @user.id)
|
||||
m.merge!(created_by_id: @user.id, last_modified_by_id: @user.id)
|
||||
end
|
||||
|
||||
@params.merge(repository_id: @repository.id, created_by_id: @user.id, data_type: @column_type)
|
||||
|
|
|
@ -35,7 +35,6 @@ module RepositoryColumns
|
|||
|
||||
to_be_created.each do |item|
|
||||
RepositoryChecklistItem.create!(
|
||||
repository: @repository,
|
||||
repository_column: @column,
|
||||
data: item,
|
||||
created_by: @user,
|
||||
|
|
|
@ -35,7 +35,6 @@ module RepositoryColumns
|
|||
|
||||
to_be_created.each do |item|
|
||||
RepositoryListItem.create!(
|
||||
repository: @repository,
|
||||
repository_column: @column,
|
||||
data: item,
|
||||
created_by: @user,
|
||||
|
|
|
@ -11,58 +11,20 @@ module RepositoryRows
|
|||
@repository = repository
|
||||
@user = user
|
||||
@params = params
|
||||
@assigned_rows_names = []
|
||||
@assigned_rows_names = Set[]
|
||||
@errors = {}
|
||||
end
|
||||
|
||||
def call
|
||||
return self unless valid?
|
||||
|
||||
downstream_modules = []
|
||||
downstream_records = {}
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
unassigned_rows = @repository.repository_rows
|
||||
.joins("LEFT OUTER JOIN my_module_repository_rows "\
|
||||
"ON repository_rows.id = my_module_repository_rows.repository_row_id "\
|
||||
"AND my_module_repository_rows.my_module_id = #{@my_module.id.to_i}")
|
||||
.where(my_module_repository_rows: { id: nil })
|
||||
.where(id: @params[:selected_rows])
|
||||
|
||||
unassigned_rows.find_each do |repository_row|
|
||||
MyModuleRepositoryRow.create!(my_module: @my_module, repository_row: repository_row, assigned_by: @user)
|
||||
@assigned_rows_names << repository_row.name
|
||||
|
||||
next unless @params[:downstream] == 'true'
|
||||
|
||||
unassigned_downstream_modules = @my_module.downstream_modules
|
||||
.left_outer_joins(:my_module_repository_rows)
|
||||
.where.not(my_module_repository_rows: { repository_row: record })
|
||||
|
||||
unassigned_downstream_modules.each do |downstream_module|
|
||||
next if my_module.repository_rows.include?(repository_row)
|
||||
|
||||
downstream_records[my_module.id] = [] unless downstream_records[downstream_module.id]
|
||||
MyModuleRepositoryRow.create!(
|
||||
my_module: downstream_module,
|
||||
repository_row: repository_row,
|
||||
assigned_by: @user
|
||||
)
|
||||
downstream_records[downstream_module.id] << repository_row.name
|
||||
downstream_modules.push(downstream_module)
|
||||
end
|
||||
|
||||
if @assigned_rows_names.present?
|
||||
@assigned_rows_names.uniq!
|
||||
log_activity(@my_module,
|
||||
repository: @repository.id,
|
||||
record_names: @assigned_rows_names.join(', '))
|
||||
downstream_modules.uniq.each do |downstream_module|
|
||||
log_activity(downstream_module,
|
||||
repository: @repository.id,
|
||||
record_names: downstream_records[my_module.id].join(', '))
|
||||
end
|
||||
if params[:downstream] == 'true'
|
||||
@my_module.downstream_modules.each do |downstream_module|
|
||||
assign_repository_rows_to_my_module(downstream_module)
|
||||
end
|
||||
else
|
||||
assign_repository_rows_to_my_module(@my_module)
|
||||
end
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
@errors[e.record.class.name.underscore] = e.record.errors.full_messages
|
||||
|
@ -78,16 +40,35 @@ module RepositoryRows
|
|||
|
||||
private
|
||||
|
||||
def log_activity(my_module = nil, message_items = {})
|
||||
message_items = { my_module: my_module.id }.merge(message_items)
|
||||
def assign_repository_rows_to_my_module(my_module)
|
||||
assigned_names = []
|
||||
unassigned_rows = @repository.repository_rows
|
||||
.joins("LEFT OUTER JOIN my_module_repository_rows "\
|
||||
"ON repository_rows.id = my_module_repository_rows.repository_row_id "\
|
||||
"AND my_module_repository_rows.my_module_id = #{my_module.id.to_i}")
|
||||
.where(my_module_repository_rows: { id: nil })
|
||||
.where(id: @params[:selected_rows])
|
||||
|
||||
Activities::CreateActivityService
|
||||
.call(activity_type: :assign_repository_record,
|
||||
owner: current_user,
|
||||
team: my_module.experiment.project.team,
|
||||
project: my_module.experiment.project,
|
||||
subject: my_module,
|
||||
message_items: message_items)
|
||||
return [] unless unassigned_rows.any?
|
||||
|
||||
unassigned_rows.find_each do |repository_row|
|
||||
MyModuleRepositoryRow.create!(my_module: my_module,
|
||||
repository_row: repository_row,
|
||||
assigned_by: @user)
|
||||
assigned_names << repository_row.name
|
||||
end
|
||||
|
||||
return [] if assigned_names.blank?
|
||||
|
||||
Activities::CreateActivityService.call(activity_type: :assign_repository_record,
|
||||
owner: @user,
|
||||
team: my_module.experiment.project.team,
|
||||
project: my_module.experiment.project,
|
||||
subject: my_module,
|
||||
message_items: { my_module: my_module.id,
|
||||
repository: @repository.id,
|
||||
record_names: assigned_names.join(', ') })
|
||||
@assigned_rows_names.merge(assigned_names)
|
||||
end
|
||||
|
||||
def valid?
|
||||
|
|
|
@ -11,7 +11,7 @@ module RepositoryRows
|
|||
@repository = repository
|
||||
@user = user
|
||||
@params = params
|
||||
@unassigned_rows_names = []
|
||||
@unassigned_rows_names = Set[]
|
||||
@errors = {}
|
||||
end
|
||||
|
||||
|
@ -19,14 +19,14 @@ module RepositoryRows
|
|||
return self unless valid?
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
@unassigned_rows_names = unassign_repository_rows_from_my_module(@my_module)
|
||||
|
||||
if params[:downstream] == 'true'
|
||||
@my_module.downstream_modules.each do |downstream_module|
|
||||
unassign_repository_rows_from_my_module(downstream_module)
|
||||
end
|
||||
else
|
||||
unassign_repository_rows_from_my_module(@my_module)
|
||||
end
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
rescue StandardError => e
|
||||
@errors[e.record.class.name.underscore] = e.record.errors.full_messages
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
|
@ -65,7 +65,7 @@ module RepositoryRows
|
|||
repository: @repository.id,
|
||||
record_names: unassigned_names.join(', ') })
|
||||
|
||||
unassigned_names
|
||||
@unassigned_rows_names.merge(unassigned_names)
|
||||
end
|
||||
|
||||
def valid?
|
||||
|
|
|
@ -83,7 +83,6 @@ module Tasks
|
|||
last_modified_by = item['last_modified_by_id'] || team.created_by_id
|
||||
timestamp = conn.quote(Time.now.to_s(:db))
|
||||
values = [
|
||||
repository.id,
|
||||
sample_group.id,
|
||||
conn.quote(item.fetch('name') { "sample group item (#{index})" }),
|
||||
created_by,
|
||||
|
@ -93,8 +92,7 @@ module Tasks
|
|||
]
|
||||
list_item_sql = <<-SQL
|
||||
INSERT INTO repository_list_items
|
||||
(repository_id,
|
||||
repository_column_id,
|
||||
(repository_column_id,
|
||||
data,
|
||||
created_by_id,
|
||||
last_modified_by_id,
|
||||
|
@ -109,7 +107,6 @@ module Tasks
|
|||
last_modified_by = item['last_modified_by_id'] || team.created_by_id
|
||||
timestamp = conn.quote(Time.now.to_s(:db))
|
||||
values = [
|
||||
repository.id,
|
||||
sample_type.id,
|
||||
conn.quote(item.fetch('name') { "sample type item (#{index})" }),
|
||||
created_by,
|
||||
|
@ -119,8 +116,7 @@ module Tasks
|
|||
]
|
||||
list_item_sql = <<-SQL
|
||||
INSERT INTO repository_list_items
|
||||
(repository_id,
|
||||
repository_column_id,
|
||||
(repository_column_id,
|
||||
data,
|
||||
created_by_id,
|
||||
last_modified_by_id,
|
||||
|
|
|
@ -75,8 +75,7 @@ module FirstTimeDataGenerator
|
|||
data: name,
|
||||
created_by: user,
|
||||
last_modified_by: user,
|
||||
repository_column: repository_column_sample_types,
|
||||
repository: repository
|
||||
repository_column: repository_column_sample_types
|
||||
)
|
||||
|
||||
# Check if it already exists
|
||||
|
@ -96,8 +95,7 @@ module FirstTimeDataGenerator
|
|||
data: name,
|
||||
created_by: user,
|
||||
last_modified_by: user,
|
||||
repository_column: repository_column_sample_groups,
|
||||
repository: repository
|
||||
repository_column: repository_column_sample_groups
|
||||
)
|
||||
|
||||
# Check if it already exists
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
FactoryBot.define do
|
||||
factory :repository_checklist_item do
|
||||
data { Faker::Lorem.paragraph }
|
||||
repository
|
||||
repository_column { create :repository_column, :checklist_type, repository: repository }
|
||||
repository_column { create :repository_column, :checklist_type }
|
||||
created_by { create :user }
|
||||
last_modified_by { created_by }
|
||||
end
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
FactoryBot.define do
|
||||
factory :repository_list_item do
|
||||
data { Faker::Lorem.paragraph }
|
||||
repository
|
||||
repository_column { create :repository_column, :list_type, repository: repository }
|
||||
repository_column { create :repository_column, :list_type }
|
||||
created_by { create :user }
|
||||
last_modified_by { created_by }
|
||||
end
|
||||
|
|
|
@ -4,7 +4,6 @@ FactoryBot.define do
|
|||
factory :repository_status_item do
|
||||
sequence(:icon) { '😀' }
|
||||
sequence(:status) { |n| "status-#{n}" }
|
||||
repository
|
||||
repository_column
|
||||
created_by { create :user }
|
||||
end
|
||||
|
|
|
@ -27,9 +27,4 @@ describe MyModuleRepositoryRow, type: :model do
|
|||
it { should belong_to(:assigned_by).class_name('User').optional }
|
||||
it { should belong_to(:repository_row) }
|
||||
end
|
||||
|
||||
describe 'Validations' do
|
||||
it { should validate_presence_of :repository_row }
|
||||
it { should validate_presence_of :my_module }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,14 +15,12 @@ RSpec.describe RepositoryChecklistItem, type: :model do
|
|||
|
||||
describe 'Database table' do
|
||||
it { should have_db_column :data }
|
||||
it { should have_db_column :repository_id }
|
||||
it { should have_db_column :created_by_id }
|
||||
it { should have_db_column :last_modified_by_id }
|
||||
it { should have_db_column :repository_column_id }
|
||||
end
|
||||
|
||||
describe 'Relations' do
|
||||
it { should belong_to :repository }
|
||||
it { should belong_to :repository_column }
|
||||
it { should belong_to(:created_by).class_name('User') }
|
||||
it { should belong_to(:last_modified_by).class_name('User') }
|
||||
|
|
|
@ -15,7 +15,6 @@ RSpec.describe RepositoryListItem, type: :model do
|
|||
|
||||
describe 'Database table' do
|
||||
it { should have_db_column :data }
|
||||
it { should have_db_column :repository_id }
|
||||
it { should have_db_column :created_by_id }
|
||||
it { should have_db_column :last_modified_by_id }
|
||||
it { should have_db_column :repository_column_id }
|
||||
|
@ -23,7 +22,6 @@ RSpec.describe RepositoryListItem, type: :model do
|
|||
|
||||
describe 'Relations' do
|
||||
it { should have_many :repository_list_values }
|
||||
it { should belong_to :repository }
|
||||
it { should belong_to :repository_column }
|
||||
it { should belong_to(:created_by).class_name('User') }
|
||||
it { should belong_to(:last_modified_by).class_name('User') }
|
||||
|
|
|
@ -90,7 +90,7 @@ RSpec.describe RepositoryListValue, type: :model 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.repository, repository_column: column }
|
||||
let(:list_item) { create :repository_list_item, repository_column: column }
|
||||
let(:attributes) do
|
||||
{
|
||||
repository_cell: cell,
|
||||
|
|
|
@ -23,7 +23,7 @@ describe RepositoryRow, type: :model do
|
|||
end
|
||||
|
||||
describe 'Relations' do
|
||||
it { should belong_to(:repository).optional }
|
||||
it { should belong_to(:repository) }
|
||||
it { should belong_to(:created_by).class_name('User') }
|
||||
it { should belong_to(:last_modified_by).class_name('User') }
|
||||
it { should have_many :repository_cells }
|
||||
|
|
|
@ -27,7 +27,6 @@ describe Repository, type: :model do
|
|||
it { should have_many :repository_rows }
|
||||
it { should have_many :repository_table_states }
|
||||
it { should have_many :report_elements }
|
||||
it { should have_many(:repository_list_items).dependent(:destroy) }
|
||||
it { should have_many(:team_repositories).dependent(:destroy) }
|
||||
it { should have_many(:teams_shared_with) }
|
||||
end
|
||||
|
|
|
@ -10,10 +10,6 @@ describe RepositoryStatusItem do
|
|||
end
|
||||
|
||||
describe 'Validations' do
|
||||
describe '#repository' do
|
||||
it { is_expected.to validate_presence_of(:repository) }
|
||||
end
|
||||
|
||||
describe '#icon' do
|
||||
it { is_expected.to validate_presence_of(:icon) }
|
||||
end
|
||||
|
@ -25,7 +21,6 @@ describe RepositoryStatusItem do
|
|||
end
|
||||
|
||||
describe 'Associations' do
|
||||
it { is_expected.to belong_to(:repository) }
|
||||
it { is_expected.to belong_to(:repository_column) }
|
||||
it { is_expected.to belong_to(:created_by).optional }
|
||||
it { is_expected.to belong_to(:last_modified_by).optional }
|
||||
|
|
|
@ -60,7 +60,7 @@ describe RepositoryStatusValue do
|
|||
let(:user) { create :user }
|
||||
let(:column) { create :repository_column }
|
||||
let(:cell) { build :repository_cell, repository_column: column }
|
||||
let(:list_item) { create :repository_status_item, repository: column.repository, repository_column: column }
|
||||
let(:list_item) { create :repository_status_item, repository_column: column }
|
||||
let(:attributes) do
|
||||
{
|
||||
repository_cell: cell,
|
||||
|
|
|
@ -10,38 +10,27 @@ RSpec.describe 'Api::V1::InventoryCellsController', type: :request do
|
|||
create(:user_team, user: @user, team: @team, role: 2)
|
||||
|
||||
# valid_inventory
|
||||
@valid_inventory = create(:repository, name: Faker::Name.unique.name,
|
||||
created_by: @user, team: @team)
|
||||
@valid_inventory = create(:repository, name: Faker::Name.unique.name, created_by: @user, team: @team)
|
||||
|
||||
# unaccessable_inventory
|
||||
@wrong_inventory = create(:repository, name: Faker::Name.unique.name,
|
||||
created_by: @user, team: @wrong_team)
|
||||
@wrong_inventory = create(:repository, name: Faker::Name.unique.name, created_by: @user, team: @wrong_team)
|
||||
|
||||
create(:repository_row, repository: @wrong_inventory)
|
||||
|
||||
@text_column = create(:repository_column, name: Faker::Name.unique.name,
|
||||
repository: @valid_inventory, data_type: :RepositoryTextValue)
|
||||
@list_column = create(:repository_column, name: Faker::Name.unique.name,
|
||||
repository: @valid_inventory, data_type: :RepositoryListValue)
|
||||
list_item =
|
||||
create(:repository_list_item, repository: @valid_inventory,
|
||||
repository_column: @list_column, data: Faker::Name.unique.name)
|
||||
second_list_item =
|
||||
create(:repository_list_item, repository: @valid_inventory,
|
||||
repository_column: @list_column, data: Faker::Name.unique.name)
|
||||
list_item = create(:repository_list_item, repository_column: @list_column, data: Faker::Name.unique.name)
|
||||
second_list_item = create(:repository_list_item, repository_column: @list_column, data: Faker::Name.unique.name)
|
||||
@status_column = create(:repository_column, repository: @valid_inventory, data_type: :RepositoryStatusValue)
|
||||
status_item = create(:repository_status_item,
|
||||
repository: @valid_inventory,
|
||||
repository_column: @status_column)
|
||||
second_status_item = create(:repository_status_item,
|
||||
repository: @valid_inventory,
|
||||
repository_column: @status_column)
|
||||
status_item = create(:repository_status_item, repository_column: @status_column)
|
||||
second_status_item = create(:repository_status_item, repository_column: @status_column)
|
||||
@checklist_column = create(:repository_column, name: Faker::Name.unique.name,
|
||||
repository: @valid_inventory, data_type: :RepositoryChecklistValue)
|
||||
checklist_items =
|
||||
create_list(:repository_checklist_item, 3, repository: @valid_inventory, repository_column: @checklist_column)
|
||||
checklist_items = create_list(:repository_checklist_item, 3, repository_column: @checklist_column)
|
||||
checklist_item =
|
||||
create(:repository_checklist_item, repository: @valid_inventory,
|
||||
repository_column: @checklist_column, data: Faker::Name.unique.name)
|
||||
create(:repository_checklist_item, repository_column: @checklist_column, data: Faker::Name.unique.name)
|
||||
@file_column = create(:repository_column, name: Faker::Name.unique.name,
|
||||
repository: @valid_inventory, data_type: :RepositoryAssetValue)
|
||||
asset = create(:asset)
|
||||
|
|
|
@ -24,10 +24,8 @@ RSpec.describe 'Api::V1::InventoryChecklistItemsController', type: :request do
|
|||
name: Faker::Name.unique.name,
|
||||
repository: @wrong_inventory,
|
||||
data_type: :RepositoryChecklistValue)
|
||||
create_list(:repository_checklist_item, 10, repository: @valid_inventory,
|
||||
repository_column: @checklist_column)
|
||||
create(:repository_checklist_item, repository: @wrong_inventory,
|
||||
repository_column: @wrong_checklist_column)
|
||||
create_list(:repository_checklist_item, 10, repository_column: @checklist_column)
|
||||
create(:repository_checklist_item, repository_column: @wrong_checklist_column)
|
||||
|
||||
@valid_headers =
|
||||
{ 'Authorization': 'Bearer ' + generate_token(@user.id) }
|
||||
|
|
|
@ -20,12 +20,10 @@ RSpec.describe 'Api::V1::InventoryColumnsController', type: :request do
|
|||
repository: @valid_inventory, data_type: :RepositoryTextValue)
|
||||
list_column = create(:repository_column, name: Faker::Name.unique.name,
|
||||
repository: @valid_inventory, data_type: :RepositoryListValue)
|
||||
create(:repository_list_item, repository: @valid_inventory,
|
||||
repository_column: list_column, data: Faker::Name.unique.name)
|
||||
create(:repository_list_item, repository_column: list_column, data: Faker::Name.unique.name)
|
||||
status_column = create(:repository_column, name: Faker::Name.unique.name,
|
||||
repository: @valid_inventory, data_type: :RepositoryStatusValue)
|
||||
create(:repository_status_item, repository: @valid_inventory,
|
||||
repository_column: status_column, status: Faker::Name.unique.name, icon: 'icon')
|
||||
create(:repository_status_item, repository_column: status_column, status: Faker::Name.unique.name, icon: 'icon')
|
||||
create(:repository_column, name: Faker::Name.unique.name,
|
||||
repository: @valid_inventory, data_type: :RepositoryAssetValue)
|
||||
|
||||
|
|
|
@ -21,8 +21,7 @@ RSpec.describe 'Api::V1::InventoryItemsController', type: :request do
|
|||
list_column = create(:repository_column, name: Faker::Name.unique.name,
|
||||
repository: @valid_inventory, data_type: :RepositoryListValue)
|
||||
list_item =
|
||||
create(:repository_list_item, repository: @valid_inventory,
|
||||
repository_column: list_column, data: Faker::Name.unique.name)
|
||||
create(:repository_list_item, repository_column: list_column, data: Faker::Name.unique.name)
|
||||
file_column = create(:repository_column, name: Faker::Name.unique.name,
|
||||
repository: @valid_inventory, data_type: :RepositoryAssetValue)
|
||||
asset = create(:asset)
|
||||
|
|
|
@ -24,10 +24,8 @@ RSpec.describe 'Api::V1::InventoryListItemsController', type: :request do
|
|||
name: Faker::Name.unique.name,
|
||||
repository: @wrong_inventory,
|
||||
data_type: :RepositoryListValue)
|
||||
create_list(:repository_list_item, 10, repository: @valid_inventory,
|
||||
repository_column: @list_column)
|
||||
create(:repository_list_item, repository: @wrong_inventory,
|
||||
repository_column: @wrong_list_column)
|
||||
create_list(:repository_list_item, 10, repository_column: @list_column)
|
||||
create(:repository_list_item, repository_column: @wrong_list_column)
|
||||
|
||||
@valid_headers =
|
||||
{ 'Authorization': 'Bearer ' + generate_token(@user.id) }
|
||||
|
|
|
@ -12,12 +12,12 @@ RSpec.describe 'Api::V1::InventoryStatusItemsController', type: :request do
|
|||
@wrong_inventory = create(:repository, name: Faker::Name.unique.name, created_by: @user, team: @team2)
|
||||
@status_column = create(:repository_column, name: Faker::Name.unique.name, repository: @inventory,
|
||||
data_type: :RepositoryStatusValue)
|
||||
create_list(:repository_status_item, 10, repository: @inventory, repository_column: @status_column)
|
||||
create_list(:repository_status_item, 10, repository_column: @status_column)
|
||||
@list_column = create(:repository_column, name: Faker::Name.unique.name,
|
||||
repository: @inventory, data_type: :RepositoryListValue)
|
||||
@wrong_column = create(:repository_column, name: Faker::Name.unique.name, repository: @wrong_inventory,
|
||||
data_type: :RepositoryStatusValue)
|
||||
@wrong_status_item = create(:repository_status_item, repository: @wrong_inventory, repository_column: @wrong_column)
|
||||
@wrong_status_item = create(:repository_status_item, repository_column: @wrong_column)
|
||||
@valid_headers =
|
||||
{ 'Authorization': 'Bearer ' + generate_token(@user.id) }
|
||||
end
|
||||
|
|
|
@ -32,7 +32,6 @@ describe RepositoryActions::DuplicateRows do
|
|||
}
|
||||
create :repository_list_value,
|
||||
repository_list_item: create(:repository_list_item,
|
||||
repository: repository,
|
||||
repository_column: list_column,
|
||||
data: "list item (#{index})"),
|
||||
repository_cell_attributes: {
|
||||
|
|
|
@ -27,7 +27,7 @@ describe RepositoryColumns::DeleteColumnService do
|
|||
context 'when RepositoryColumn has RepositoryListItems' do
|
||||
before do
|
||||
3.times do
|
||||
create(:repository_list_item, repository: repository, repository_column: repository_column)
|
||||
create(:repository_list_item, repository_column: repository_column)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -39,7 +39,7 @@ describe RepositoryColumns::DeleteColumnService do
|
|||
context 'when RepositoryColumn has RepositoryStatusItems' do
|
||||
before do
|
||||
3.times do
|
||||
create(:repository_status_item, repository: repository, repository_column: repository_column)
|
||||
create(:repository_status_item, repository_column: repository_column)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ describe RepositoryColumns::UpdateColumnService do
|
|||
let(:team) { create :team }
|
||||
let(:repository) { create :repository, team: team }
|
||||
let(:column) { create :repository_column, :status_type }
|
||||
let(:status_item) { create(:repository_status_item, repository: repository, repository_column: column) }
|
||||
let(:status_item) { create(:repository_status_item, repository_column: column) }
|
||||
let(:service_call) do
|
||||
RepositoryColumns::UpdateColumnService.call(column: column,
|
||||
user: user,
|
||||
|
@ -80,7 +80,7 @@ describe RepositoryColumns::UpdateColumnService do
|
|||
|
||||
context 'when updates column\'s list items' do
|
||||
let(:column) { create :repository_column, :list_type }
|
||||
let(:list_item) { create(:repository_list_item, repository: repository, repository_column: column) }
|
||||
let(:list_item) { create(:repository_list_item, repository_column: column) }
|
||||
|
||||
let(:params) do
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ describe RepositoryColumns::UpdateListColumnService do
|
|||
let(:team) { create :team }
|
||||
let(:repository) { create :repository, team: team }
|
||||
let(:column) { create :repository_column, :list_type }
|
||||
let(:list_item) { create(:repository_list_item, repository: repository, repository_column: column) }
|
||||
let(:list_item) { create(:repository_list_item, repository_column: column) }
|
||||
let(:service_call) do
|
||||
RepositoryColumns::UpdateListColumnService.call(column: column,
|
||||
user: user,
|
||||
|
@ -32,7 +32,7 @@ describe RepositoryColumns::UpdateListColumnService do
|
|||
|
||||
context 'when changing list items' do
|
||||
let(:column) { create :repository_column, :list_type }
|
||||
let(:list_item) { create(:repository_list_item, repository: repository, repository_column: column) }
|
||||
let(:list_item) { create(:repository_list_item, repository_column: column) }
|
||||
|
||||
context 'when adding list item' do
|
||||
let(:params) do
|
||||
|
|
|
@ -34,7 +34,6 @@ describe RepositoryDatatableService do
|
|||
let!(:list_item) do
|
||||
create :repository_list_item,
|
||||
data: 'bug',
|
||||
repository: repository,
|
||||
repository_column: repository_column,
|
||||
created_by: user,
|
||||
last_modified_by: user
|
||||
|
|
|
@ -15,9 +15,7 @@ describe RepositoryZipExport, type: :background_job do
|
|||
data_type: 'RepositoryListValue'
|
||||
end
|
||||
let!(:repository_list_item) do
|
||||
create :repository_list_item, data: 'item one',
|
||||
repository: repository,
|
||||
repository_column: sample_group_column
|
||||
create :repository_list_item, data: 'item one', repository_column: sample_group_column
|
||||
end
|
||||
let!(:custom_column) do
|
||||
create :repository_column, repository: repository,
|
||||
|
|
Loading…
Reference in a new issue