Merge pull request #1446 from Ducz0r/lm-remove-test-folder

Remove test folder
This commit is contained in:
Luka Murn 2019-01-21 14:07:22 +01:00 committed by GitHub
commit 38d303b658
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
122 changed files with 0 additions and 4884 deletions

View file

@ -149,33 +149,6 @@ class AddonGenerator < Rails::Generators::NamedBase
end
end
def create_test
# test/fixtures
create_file("addons/#{@addon_name}/test/fixtures/#{@folders_path}/.keep")
# test/integrations
create_file("addons/#{@addon_name}/test/integrations/.keep")
# test/models
create_file("addons/#{@addon_name}/test/models/#{@folders_path}/.keep")
# test/engine_test
create_file(
"addons/#{@addon_name}/test/" \
"#{@folders_path}/#{@addon_name}_test.rb"
) do
"require 'test_helper'\n\n" \
"class #{name}::Test < ActiveSupport::TestCase\n" \
" test 'truth' do\n" \
" assert_kind_of Module, #{name}\n" \
" end\n" \
"end\n"
end
# test/test_helper.rb
copy_file('test_helper.rb', "addons/#{@addon_name}/test/test_helper.rb")
end
def create_root
copy_file('.gitignore', "addons/#{@addon_name}/.gitignore")
copy_file('Gemfile', "addons/#{@addon_name}/Gemfile")

View file

@ -1,24 +0,0 @@
# Configure Rails Environment
ENV['RAILS_ENV'] = 'test'
require File.expand_path('../..//config/environment.rb', __FILE__)
ActiveRecord::Migrator.migrations_paths = [
File.expand_path('../..//db/migrate', __FILE__)
]
require 'rails/test_help'
# Filter out Minitest backtrace while allowing backtrace from other libraries
# to be shown.
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
# Load fixtures from the engine
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
ActiveSupport::TestCase.fixture_path =
File.expand_path('../fixtures', __FILE__)
ActiveSupport::TestCase.file_fixture_path =
ActiveSupport::TestCase.fixture_path + 'files'
ActiveSupport::TestCase.fixtures :all
end

View file

View file

@ -1,5 +0,0 @@
require 'test_helper'
class ActivitiesControllerTest < ActionController::TestCase
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class CustomFieldsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class MyModulesControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class ProjectActivitiesControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class ProjectsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class ResultAssetsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class ResultCommentsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class ResultTablesControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class ResultTextsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class SampleGroupsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class SampleTypesControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class SamplesControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class SearchControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class StepCommentsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class StepsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class TeamsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -1,7 +0,0 @@
require 'test_helper'
class UserMyModulesControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

0
test/fixtures/.keep vendored
View file

View file

@ -1,95 +0,0 @@
one:
project: interfaces
my_module: qpcr
user: steve
type_of: assignment
message: User Steve assigned module lalala to user Jlaw.
created_at: 2015-11-01 10:01:01
two:
project: interfaces
my_module: qpcr
user: steve
type_of: result
message: User Steve added result to step 2 of module qPCR.
created_at: 2015-11-01 10:02:01
three:
project: interfaces
my_module: qpcr
user: steve
type_of: result
message: User Steve added result to step 3 of module qPCR.
created_at: 2015-11-01 10:03:01
four:
project: interfaces
my_module: rna_test
user: steve
type_of: assignment
message: User Steve assigned module lalala to user Jlaw.
created_at: 2015-11-01 10:04:01
five:
project: interfaces
my_module: rna_test
user: steve
type_of: result
message: User Steve added result to step 2 of module RNA test.
created_at: 2015-11-01 10:05:01
six:
project: interfaces
my_module: rna_test
user: steve
type_of: result
message: User Steve added result to step 3 of module RNA test.
created_at: 2015-11-01 10:06:01
seven:
project: interfaces
my_module: sample_prep
user: steve
type_of: assignment
message: User Steve assigned module lalala to user Jlaw.
created_at: 2015-11-01 10:07:01
eight:
project: interfaces
my_module: sample_prep
user: steve
type_of: result
message: User Steve added result to step 2 of module Sample preparation.
created_at: 2015-11-01 10:08:01
nine:
project: interfaces
my_module: sample_prep
user: steve
type_of: result
message: User Steve added result to step 3 of module Sample preparation.
created_at: 2015-11-01 10:09:01
ten:
project: interfaces
my_module: list_of_samples
user: steve
type_of: assignment
message: User Steve assigned module lalala to user Jlaw.
created_at: 2015-11-01 10:10:01
eleven:
project: interfaces
my_module: list_of_samples
user: steve
type_of: result
message: User Steve added result to step 2 of module List of samples.
created_at: 2015-11-01 10:11:01
twelve:
project: interfaces
my_module: list_of_samples
user: steve
type_of: result
message: User Steve added result to step 3 of module List of samples.
created_at: 2015-11-01 10:12:01

View file

@ -1,15 +0,0 @@
one:
asset: one
data: This is text content of asset file #1.
two:
asset: two
data: This is text content of asset file #2.
invalid_asset_id:
asset_id: 12321321
data: This is text content of invalid asset.
invalid_asset_value:
asset: nil
data: This is text content of nil asset.

View file

@ -1,48 +0,0 @@
one:
file_file_name: file1.pdf
file_content_type: application/pdf
file_file_size: 15
estimated_size: <%= (15 * Constants::ASSET_ESTIMATED_SIZE_FACTOR).to_i %>
created_by: steve
last_modified_by: steve
two:
file_file_name: file2.zip
file_content_type: application/zip
file_file_size: 32
estimated_size: <%= (32 * Constants::ASSET_ESTIMATED_SIZE_FACTOR).to_i %>
created_by: mark
last_modified_by: mark
three:
file_file_name: file3.jpg
file_content_type: image/jpg
file_file_size: 64
estimated_size: <%= (64 * Constants::ASSET_ESTIMATED_SIZE_FACTOR).to_i %>
created_by: mark
last_modified_by: jlaw
four:
file_file_name: file4.png
file_content_type: image/png
file_file_size: 128
estimated_size: <%= (128 * Constants::ASSET_ESTIMATED_SIZE_FACTOR).to_i %>
created_by: steve
last_modified_by: jlaw
test:
file_file_name: file7.png
file_content_type: image/png
file_file_size: 578
estimated_size: <%= (578 * Constants::ASSET_ESTIMATED_SIZE_FACTOR).to_i %>
created_by: steve
last_modified_by: jlaw
test_result:
file_file_name: file8.png
file_content_type: image/png
file_file_size: 631
estimated_size: <%= (631 * Constants::ASSET_ESTIMATED_SIZE_FACTOR).to_i %>
created_by: steve
last_modified_by: steve

View file

@ -1,56 +0,0 @@
one:
text: "Checklist Item 1"
checked: true
checklist: one
created_by: steve
last_modified_by: steve
two:
text: "Checklist Item 2"
checked: false
checklist: one
created_by: mark
last_modified_by: mark
three:
text: "Checklist Item 3"
checked: false
checklist: one
created_by: steve
last_modified_by: mark
four:
text: "Checklist Item 4"
checked: true
checklist: two
created_by: jlaw
last_modified_by: jlaw
five:
text: "Checklist Item 5"
checked: false
checklist: two
created_by: steve
last_modified_by: nora
six:
text: "Checklist Item 6"
checked: true
checklist: two
created_by: mark
last_modified_by: mark
seven:
text: "Checklist Item 7"
checked: false
checklist: three
created_by: mark
last_modified_by: steve
eight:
text: "Checklist Item 8"
checked: false
checklist: three
created_by: nora
last_modified_by: steve

View file

@ -1,17 +0,0 @@
one:
name: "Checklist 1"
step: step1
created_by: steve
last_modified_by: steve
two:
name: "Checklist 2"
step: step2
created_by: steve
last_modified_by: jlaw
three:
name: "Checklist 3"
step: step3
created_by: nora
last_modified_by: jlaw

View file

@ -1,89 +0,0 @@
one:
message: "Good job, JLaw, very comprehensive results!"
user: steve
two:
message: "This doesn't look so good, please repeat the experiment."
user: steve
three:
message: "Consider it done!"
user: nora
four:
message: "I still have to write abstract."
user: mark
five:
message: "Ok, I will do it tomorrow."
user: mark
six:
message: "Ok"
user: jlaw
seven:
message: "Nah, I don't feel like it."
user: jlaw
eight:
message: "I don't have time now, maybe tomorrow."
user: jlaw
nine:
message: "This is project comment."
user: mark
ten:
message: "This is module comment."
user: mark
eleven:
message: "This is module comment 2."
user: nora
twelve:
message: "This is project comment 2."
user: nora
thirteen:
message: "Random comment 1"
user: john
fourteen:
message: "Random comment 2"
user: john
fifteen:
message: "Random comment 3"
user: john
sixteen:
message: "Congrats!"
user: jlaw
seventeen:
message: "Congrats, aswell!"
user: nora
test:
message: "This is test message"
user: nora
<% 25.times do |n| %>
test_step_comment_<%= n %>:
message: "This is test message #<%= n %>"
user: steve
created_at: "2015-11-06 11:<%= n.to_s.rjust(2, '0') %>:00"
<% end %>
<% 25.times do |n| %>
test_result_comment_<%= n %>:
message: "This is test message #<%= n %>"
user: steve
created_at: "2015-11-06 11:<%= n.to_s.rjust(2, '0') %>:00"
<% end %>
unassociated:
message: This message is not associated with any entity
user: nora

View file

@ -1,19 +0,0 @@
one:
from: list_of_samples
to: sample_prep
two:
from: sample_prep
to: qpcr
three:
from: qpcr
to: quantification
four:
from: list_of_samples
to: rna_test
five:
from: rna_test
to: quantification

View file

@ -1,14 +0,0 @@
volume:
name: "Volume"
user: steve
team: biosistemika
location:
name: "Location"
user: jlaw
team: biosistemika
description:
name: "Description"
user: nora
team: nib

View file

@ -1,8 +0,0 @@
philadelphia:
name: PHILADELPHIA
description: experiment
project: interfaces
created_at: 2012-05-09 16:23:33
created_by: steve
last_modified_by: steve
updated_at: 2012-05-09 16:23:33

View file

@ -1,7 +0,0 @@
one:
team: biosistemika
message: This is a test log numero uno
two:
team: biosistemika
message: This is a test log numero due

View file

@ -1,23 +0,0 @@
one:
my_module: list_of_samples
comment: thirteen
two:
my_module: sample_prep
comment: fourteen
three:
my_module: sample_prep
comment: fifteen
four:
my_module: qpcr
comment: sixteen
five:
my_module: quantification
comment: seventeen
test:
my_module: qpcr
comment: eleven

View file

@ -1,14 +0,0 @@
wf1:
name: Workflow 1
experiment: philadelphia
created_by: mark
ge:
name: Gene Expression
experiment: philadelphia
created_by: steve
wf2:
name: Workflow 2
experiment: philadelphia
created_by: jlaw

View file

@ -1,140 +0,0 @@
list_of_samples:
name: List of samples
due_date: 2015-11-10 12:00:00
description: Listing samples...
x: 0
y: 0
workflow_order: 0
experiment: philadelphia
my_module_group: ge
tags: urgent, nice
created_by: steve
last_modified_by: steve
archived: false
archived_by:
restored_by:
archived_on:
restored_on:
sample_prep:
name: Sample preparation
due_date: 12-04-2015 12:45:00
description: nil
x: 1
y: 0
workflow_order: 2
experiment: philadelphia
my_module_group: ge
created_by: mark
last_modified_by: mark
archived: false
archived_by: steve
restored_by: steve
archived_on: 2012-09-10 16:23:35
restored_on: 2012-10-05 06:03:33
qpcr:
name: qPCR
due_date: 12-04-2015 15:10:00
description: nil
x: 2
y: 0
workflow_order: 3
experiment: philadelphia
my_module_group: ge
tags: nice
created_by: jlaw
last_modified_by: jlaw
archived: false
archived_by:
restored_by:
archived_on:
restored_on:
quantification:
name: Quantification
due_date: "04-13-2015 09:45:00"
description: nil
x: 3
y: 0
workflow_order: 4
experiment: philadelphia
my_module_group: ge
tags: todo
created_by: mark
last_modified_by: mark
archived: false
archived_by:
restored_by:
archived_on:
restored_on:
rna_test:
name: RNA quality test
due_date: 12-04-2015 16:15:00
description: nil
x: 1
y: 1
workflow_order: 1
experiment: philadelphia
my_module_group: ge
tags: urgent, todo
created_by: steve
last_modified_by: steve
archived: false
archived_by: mark
restored_by: mark
archived_on: 2012-02-09 16:23:35
restored_on: 2012-12-09 12:33:48
custom:
name: Unknown module
due_date:
description: Hodor hodor hodor.
x: 0
y: 0
workflow_order: -1
experiment: philadelphia
my_module_group: wf1
created_by: steve
last_modified_by: steve
archived: false
archived_by:
restored_by:
archived_on:
restored_on:
no_group:
name: No group module
due_date:
description: Module without group
x: 0
y: 3
workflow_order: -1
experiment: philadelphia
my_module_group: wf2
created_by: nora
last_modified_by: nora
archived: false
archived_by:
restored_by:
archived_on:
restored_on:
archived:
name: Archived module
due_date:
description: Module in archive
x: 0
y: 0
workflow_order: -1
experiment: philadelphia
my_module_group:
created_by: steve
last_modified_by: steve
archived: true
archived_by: jlaw
restored_by:
archived_on: 2015-11-16 10:25:34
restored_on:

View file

@ -1,9 +0,0 @@
one:
title: 'Notification one'
message: 'Message for notification one'
type_of: 1
two:
title: 'Notification two'
message: 'Message for notification two'
type_of: 1

View file

@ -1,15 +0,0 @@
one:
project: interfaces
comment: seven
two:
project: interfaces
comment: eight
three:
project: interfaces
comment: nine
test:
project: interfaces
comment: six

View file

@ -1,175 +0,0 @@
interfaces:
name: INTERFACES
visibility: 1
due_date: 2015-11-02 15:30:22
team: biosistemika
archived: false
archived_on:
created_at: 2015-11-01 11:37:26
created_by: steve
last_modified_by: steve
archived_by:
restored_by:
restored_on:
eurostars:
name: EUROSTARS
visibility: 1
due_date: 2015-11-02 15:30:22
team: biosistemika
archived: false
archived_on:
created_at: 2015-11-01 12:53:07
created_by: steve
last_modified_by: steve
archived_by:
restored_by:
restored_on:
krop:
name: KROP 2012
visibility: 1
due_date: 2012-05-07 13:30:25
team: biosistemika
archived: true
archived_on: 2012-05-09 16:23:33
created_by: mark
last_modified_by: mark
archived_by: mark
restored_by:
restored_on:
phd:
name: PhD Thesis
visibility: 0
due_date:
team: nib
archived: false
archived_on:
created_by: mark
last_modified_by: steve
archived_by:
restored_by:
restored_on:
decathlon:
name: DECATHLON
visibility: 1
due_date:
team: phylos
archived: false
archived_on:
created_by: jlaw
last_modified_by: jlaw
archived_by:
restored_by:
restored_on:
valor:
name: VALOR 2010
visibility: 1
due_date: 2010-11-13 14:11:23
team: nib
archived: false
archived_on: 2012-05-09 16:33:33
created_by: nora
last_modified_by: nora
archived_by: mark
restored_by: mark
restored_on: 2014-09-15 11:43:22
secret:
name: My Secret Life
visibility: 0
due_date: 2030-06-04 13:00:00
team: nib
archived: false
archived_on:
created_by: mark
last_modified_by: steve
archived_by:
restored_by:
restored_on:
a_project:
name: A Project
visibility: 1
due_date: 2018-12-02 15:30:22
team: biosistemika
archived: false
archived_on:
created_at: 2015-11-01 14:28:15
created_by: steve
last_modified_by: steve
archived_by:
restored_by:
restored_on:
z_project:
name: Z Project
visibility: 1
due_date: 2018-12-02 15:30:22
team: biosistemika
archived: false
archived_on:
created_at: 2015-11-01 16:15:37
created_by: steve
last_modified_by: steve
archived_by:
restored_by:
restored_on:
a_archived_project:
name: A Archived Project
visibility: 1
due_date: 2018-12-02 15:30:22
team: biosistemika
archived: true
archived_on: 2015-11-05 08:14:56
created_at: 2015-11-01 14:28:15
created_by: steve
last_modified_by: steve
archived_by:
restored_by:
restored_on:
z_archived_project:
name: Z Archived Project
visibility: 1
due_date: 2018-12-02 15:30:22
team: biosistemika
archived: true
archived_on: 2015-11-05 08:12:56
created_at: 2015-11-01 16:15:37
created_by: steve
last_modified_by: steve
archived_by:
restored_by:
restored_on:
test1:
name: Project 1
visibility: 1
due_date: <%= DateTime.now %>
team: biosistemika
archived: false
created_by: steve
test2:
name: Project 2
visibility: 0
team: biosistemika
archived: true
archived_on: <%= DateTime.now %>
test3:
name: Project 3
visibility: 1
team: nib
archived: false
dummy:
name: Dummy project
visibility: 1
team: nib
archived: false

View file

@ -1,19 +0,0 @@
kw1:
name: "qPCR"
team: biosistemika
kw2:
name: "Lab"
team: biosistemika
kw3:
name: "ELISA"
team: biosistemika
kw4:
name: "Sample Prep"
team: biosistemika
kw5:
name: "Vortexing"
team: biosistemika

View file

@ -1,39 +0,0 @@
ppk1:
protocol: rna_test_protocol
protocol_keyword: kw1
ppk2:
protocol: rna_test_protocol
protocol_keyword: kw2
ppk3:
protocol: rna_test_protocol
protocol_keyword: kw3
ppk4:
protocol: rna_test_protocol
protocol_keyword: kw4
ppk5:
protocol: rna_test_protocol
protocol_keyword: kw5
ppk6:
protocol: rna_test_protocol_global
protocol_keyword: kw1
ppk7:
protocol: rna_test_protocol_global
protocol_keyword: kw2
ppk8:
protocol: rna_test_protocol_global
protocol_keyword: kw3
ppk9:
protocol: rna_test_protocol_global
protocol_keyword: kw4
ppk10:
protocol: rna_test_protocol_global
protocol_keyword: kw5

View file

@ -1,32 +0,0 @@
rna_test_protocol:
name: "RNA Test v1.0"
authors: "Schmidt, Jurgen"
description: "This is a test protocol."
added_by: steve
my_module: rna_test
team: biosistemika
protocol_type: 1
parent: rna_test_protocol_global
parent_updated_at: "2015-11-06 11:12:00"
sample_prep_protocol:
my_module: sample_prep
team: biosistemika
protocol_type: 0
list_of_samples_protocol:
name: "List samples"
description: "This is WIP, don't touch"
my_module: list_of_samples
team: biosistemika
protocol_type: 0
rna_test_protocol_global:
name: "RNA Test v1.0"
authors: "Schmidt, Jurgen"
description: "This is a test protocol."
added_by: steve
team: biosistemika
protocol_type: 3
updated_at: "2015-11-06 11:12:00"
published_on: "2015-11-06 11:12:00"

View file

@ -1,105 +0,0 @@
re_1:
report: one
position: 0
type_of: 0
project: interfaces
re_2:
report: one
position: 1
type_of: 1
my_module: list_of_samples
re_2_1:
report: one
position: 0
type_of: 2
step: step1
parent: re_2
re_2_1_1:
type_of: 8
position: 0
report: one
checklist: one
parent: re_2_1
re_2_1_2:
report: one
position: 1
type_of: 10
table: two
parent: re_2_1
re_2_1_3:
report: one
position: 2
type_of: 11
sort_order: asc
step: step1
parent: re_2_1
re_2_2:
report: one
position: 1
type_of: 4
result: four
parent: re_2
re_2_2_1:
report: one
position: 0
type_of: 12
sort_order: desc
result: four
parent: re_2_2
re_2_3:
report: one
position: 2
type_of: 6
sort_order: asc
my_module: list_of_samples
re_2_4:
report: one
position: 3
type_of: 7
sort_order: desc
my_module: list_of_samples
re_3:
report: one
position: 2
type_of: 1
sort_order: asc
my_module: sample_prep
re_4:
report: one
position: 3
type_of: 1
sort_order: asc
my_module: qpcr
re_5:
report: one
position: 4
type_of: 1
sort_order: asc
my_module: quantification
re_6:
report: one
position: 5
type_of: 1
sort_order: asc
my_module: rna_test
re_7:
report: one
position: 6
type_of: 1
sort_order: asc
my_module: no_group

View file

@ -1,5 +0,0 @@
one:
name: "Report 1"
description: "test description"
project: interfaces
user: steve

View file

@ -1,7 +0,0 @@
one:
result: two
asset: one
test:
result: test_result
asset: test_result

View file

@ -1,25 +0,0 @@
one:
result: one
comment: three
two:
result: one
comment: four
three:
result: two
comment: five
four:
result: three
comment: six
test:
result: test
comment: test
<% 25.times do |n| %>
test_<%= n %>:
result: test2
comment: test_result_comment_<%= n %>
<% end %>

View file

@ -1,7 +0,0 @@
one:
result: three
table: one
test:
result: test
table: test

View file

@ -1,7 +0,0 @@
one:
text: This is an example result text.
result: one
test:
text: This is a test result text.
result: test

View file

@ -1,66 +0,0 @@
one:
name: Result text nr. 1
my_module: rna_test
user: steve
last_modified_by: steve
#to be added after merge
#archived: false
archived_by:
#archived_on:
restored_by:
restored_on:
two:
name: My image Result
my_module: rna_test
user: steve
last_modified_by: jlaw
#to be added after merge
#archived: false
archived_by:
#archived_on:
restored_by:
restored_on:
three:
name: My table result
my_module: rna_test
user: steve
last_modified_by: jlaw
#to be added after merge
#archived: false
archived_by: steve
#archived_on: 2015-10-01 14:11:23
restored_by: jlaw
restored_on: 2015-10-05 07:01:13
four:
name: My table result
my_module: list_of_samples
user: steve
last_modified_by: jlaw
#to be added after merge
archived: true
archived_by: steve
archived_on: 2015-10-01 14:11:23
#restored_by: jlaw
#restored_on: 2015-10-05 07:01:13
test:
name: Result test
user: steve
my_module: list_of_samples
test2:
name: Another result
user: jlaw
my_module: rna_test
test_result:
name: Result test
user: steve
my_module: list_of_samples
no_items:
user: steve
my_module: sample_prep

View file

@ -1,11 +0,0 @@
one:
sample: sample1
comment: ten
two:
sample: sample1
comment: eleven
three:
sample: sample1
comment: twelve

View file

@ -1,21 +0,0 @@
one:
sample: sample1
custom_field: volume
value: "10ml"
two:
sample: sample1
custom_field: location
value: "New York"
four:
sample: sample2
custom_field: volume
value: "15ml"
five:
sample: sample2
custom_field: location
value: "Paris"

View file

@ -1,14 +0,0 @@
blood:
name: Blood
color: "#ff0000"
team: biosistemika
created_by: steve
last_modified_by: mark
noble:
name: Blue blood
color: "#0000ff"
team: biosistemika
created_by: steve
last_modified_by: steve

View file

@ -1,17 +0,0 @@
one:
sample: sample1
my_module: sample_prep
assigned_by: steve
assigned_on: 2015-09-10 10:11:57
two:
sample: sample2
my_module: sample_prep
assigned_by: jlaw
assigned_on: 2015-09-11 12:43:22
three:
sample: sample3
my_module: sample_prep
assigned_by: nora
assigned_on: 2015-09-15 16:23:35

View file

@ -1,9 +0,0 @@
skin:
name: Skin
team: biosistemika
created_by: steve
urine:
name: Urine
team: biosistemika
created_by: steve

View file

@ -1,31 +0,0 @@
sample1:
name: Cow DNA
user: steve
team: biosistemika
sample_type: urine
sample_group: blood
last_modified_by: steve
sample2:
name: Bat DNA
user: steve
team: biosistemika
sample_type: skin
sample_group: noble
last_modified_by: steve
sample3:
name: Cat DNA
user: steve
team: biosistemika
last_modified_by: jlaw
test:
name: Test Sample
user: jlaw
team: biosistemika
test2:
name: Another test sample
user: jlaw
team: biosistemika

View file

@ -1,15 +0,0 @@
one:
step: step1
asset: three
two:
step: step2
asset: four
three:
step: step3
asset: two
test:
step: test
asset: test

View file

@ -1,17 +0,0 @@
one:
step: step1
comment: one
two:
step: step1
comment: two
test:
step: test
comment: test
<% 25.times do |n| %>
test_<%= n %>:
step: test2
comment: test_step_comment_<%= n %>
<% end %>

View file

@ -1,7 +0,0 @@
one:
step: step1
table: two
test:
step: test
table: test

View file

@ -1,48 +0,0 @@
step1:
name: mRNA sequencing - preparation (1)
description: lsdkfjdfkltfgjsdkljrsdlkjrsdlrj
position: 0
completed: false
user: steve
protocol: rna_test_protocol
last_modified_by: steve
step2:
name: mRNA sequencing - preparation (2)
description: s098sdofsdufisdfusdifusdfusdfsdo
position: 1
completed: false
user: steve
protocol: rna_test_protocol
last_modified_by: jlaw
step3:
name: mRNA sequencing - preparation (3)
description: lsdkfjdfkltfgjsdkljrsdlkjrsdlrj
position: 2
completed: false
user: steve
protocol: rna_test_protocol
last_modified_by: steve
test:
name: Step test
position: 3
completed: false
user: jlaw
protocol: sample_prep_protocol
test2:
name: test
description: testing description
completed: false
user: steve
protocol: list_of_samples_protocol
position: 5
empty:
name: Step with no tables
position: 4
completed: false
user: jlaw
protocol: sample_prep_protocol

View file

@ -1,14 +0,0 @@
one:
contents: '{"data":[["1",null,null,null,"213"],["",null,null,null,"213"],["","8","4","4",null],["3","7","4","4","12312"],["5","6","4",null,"3"],["5","6",null,"5","1"],[null,"1","1","1",null],[null,null,null,null,null]]}'
created_by: steve
last_modified_by: steve
two:
contents: '{"data":[["as",null,null,null,null],[null,null,"as",null,null],[null,null,null,null,"as"],[null,null,null,"as","as"],[null,null,null,null,null]]}'
created_by: steve
last_modified_by: steve
test:
contents: Test
created_by: steve
last_modified_by: steve

View file

@ -1,34 +0,0 @@
urgent:
name: urgent
color: "#ff0000"
project: interfaces
created_by: steve
last_modified_by: jlaw
todo:
name: todo
color: "#00ff00"
project: interfaces
created_by: steve
last_modified_by: steve
classified:
name: classified
color: "#0000ff"
project: interfaces
created_by: steve
last_modified_by: jlaw
nice:
name: nice-to-have
color: "#f0000f"
project: interfaces
created_by: steve
last_modified_by: mark
old:
name: old
color: "#000ff0"
project: a_archived_project
created_by: steve
last_modified_by: mark

View file

@ -1,21 +0,0 @@
biosistemika:
name: BioSistemika
created_by: steve
description: "The best company in the world!"
nib:
name: nib
created_by: steve
phylos:
name: Phylos Bioscience
created_by: steve
test:
name: Test Team
description: "Testing team, you know"
steve_team:
name: Steve's Team
description: "Private team"
created_by: steve

View file

@ -1,5 +0,0 @@
one:
session_id: 0
file_file_name: my-avatar.jpg
file_content_type: text/plain
file_file_size: 153

View file

@ -1,47 +0,0 @@
one:
user: steve
my_module: sample_prep
assigned_by: steve
two:
user: steve
my_module: rna_test
assigned_by: jlaw
three:
user: jlaw
my_module: rna_test
assigned_by: jlaw
four:
user: steve
my_module: qpcr
assigned_by: steve
five:
user: steve
my_module: list_of_samples
assigned_by: steve
non_existing_user:
user_id: <%= Constants::INFINITY %>
my_module: rna_test
assigned_by: jlaw
non_existing_module:
user_id: jlaw
my_module_id: <%= Constants::INFINITY %>
assigned_by: jlaw
without_user:
user_id: 0
my_module: rna_test
assigned_by: jlaw
without_module:
user_id: jlaw
my_module: 0
archived:
user: steve
my_module: archived

View file

@ -1,11 +0,0 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
user_id:
notification_id:
checked: false
two:
user_id:
notification_id:
checked: false

View file

@ -1,119 +0,0 @@
one:
user: steve
project: interfaces
role: 0
assigned_by: steve
two:
user: steve
project: decathlon
role: 1
assigned_by: steve
three:
user: steve
project: valor
role: 1
assigned_by: mark
four:
user: mark
project: eurostars
role: 3
assigned_by: mark
five:
user: mark
project: phd
role: 0
assigned_by: nora
six:
user: mark
project: valor
role: 2
assigned_by: mark
seven:
user: jlaw
project: eurostars
role: 3
assigned_by: mark
eight:
user: nora
project: decathlon
role: 2
assigned_by: nora
nine:
user: nora
project: secret
role: 0
assigned_by: nora
ten:
user: nora
project: valor
role: 1
assigned_by: default
eleven:
user: jlaw
project: interfaces
role: 1
assigned_by: steve
twelve:
user: steve
project: a_project
role: 0
assigned_by: steve
thirteen:
user: steve
project: z_project
role: 0
assigned_by: steve
fourteen:
user: steve
project: a_archived_project
role: 0
assigned_by: steve
fifteen:
user: steve
project: z_archived_project
role: 0
assigned_by: steve
without_role:
user: nora
project: decathlon
role: -1
assigned_by: steve
without_user:
user: 0
project: decathlon
role: 1
assigned_by: steve
without_project:
user: nora
project: 0
role: 1
assigned_by: steve
with_invalid_user:
user_id: <%= Constants::INFINITY %>
project: decathlon
role: 1
assigned_by: steve
with_invalid_project:
user: nora
project_id: <%= Constants::INFINITY %>
role: 1
assigned_by: steve

View file

@ -1,98 +0,0 @@
one:
user: steve
team: biosistemika
role: 1
assigned_by: steve
two:
user: steve
team: nib
role: 1
assigned_by: steve
seven:
user: steve
team: phylos
role: 1
assigned_by: steve
three:
user: mark
team: biosistemika
role: 1
assigned_by: mark
four:
user: mark
team: nib
role: 2
assigned_by: mark
five:
user: jlaw
team: biosistemika
role: 0
assigned_by: steve
six:
user: nora
team: nib
role: 1
assigned_by: nora
eight:
user: nora
team: phylos
role: 2
assigned_by: nora
nine:
user: default
team: biosistemika
role: 2
assigned_by: default
ten:
user: default
team: nib
role: 2
assigned_by: default
without_role:
user: nora
team: nib
role: -1
assigned_by: steve
without_user:
user: 0
team: nib
role: 1
assigned_by: steve
without_team:
user: nora
team: 0
role: 1
assigned_by: steve
with_invalid_user:
user_id: <%= Constants::INFINITY %>
team: nib
role: 1
assigned_by: steve
with_invalid_team:
user: nora
team_id: <%= Constants::INFINITY %>
role: 1
assigned_by: steve

View file

@ -1,41 +0,0 @@
steve:
full_name: Steve Johnson
initials: SJ
email: steve.johnson@gmail.com
encrypted_password: <%= Devise::Encryptor.digest(User, 'hidden_password') %>
confirmed_at: <%= Time.now %>
john:
full_name: John Doe
initials: JD
email: john.doe@gmail.com
encrypted_password: <%= Devise::Encryptor.digest(User, '12345678') %>
confirmed_at: <%= Time.now %>
mark:
full_name: Mark Bond
initials: MB
email: mark.bond@gmail.com
encrypted_password: <%= Devise::Encryptor.digest(User, 'secret_password') %>
confirmed_at: <%= Time.now %>
jlaw:
full_name: Jennifer Lawrence
initials: JL
email: jennifer.lawrence@gmail.com
encrypted_password: <%= Devise::Encryptor.digest(User, 'jlaw_pass') %>
confirmed_at: <%= Time.now %>
nora:
full_name: Nora Jones
initials: NJ
email: nora.jones@gmail.com
encrypted_password: <%= Devise::Encryptor.digest(User, 'nora_pass') %>
confirmed_at: <%= Time.now %>
default:
full_name: Default User
initials: DU
email: my.platr@gmail.com
encrypted_password: <%= Devise::Encryptor.digest(User, '12345678') %>
confirmed_at: <%= Time.now %>

View file

@ -1,6 +0,0 @@
first:
expires: <%= Time.now + 1.days %>
proof_key_mod: '0HOWUPFFgmSYHbLZZzdWO/HUOr8YNfx5NAl7GUytooHZ7B9QxQKTJpj0NIJ4XEskQW8e4dLzRrPbNOOJ+KpWHttXz8HoQXkkZV/gYNxaNHJ8/pRXGMZzfVM5vchhx/2C7ULPTrpBsSpmfWQ6ShaVoQzfThFUd0MsBvIN7HVtqzPx9jbSV04wAqyNjcro7F3iu9w7AEsMejHbFlWoN+J05dP5ixryF7+2U5RVmjMt7/dYUdCoiXvCMt2CaVr0XEG6udHU4iDKVKZjmUBc7cTWRzhqEL7lZ1yQfylp38Nd2xxVJ0sSU7OkC1bBDlePcYGaF3JjJgsmp/H5BNnlW9gSxQ=='
proof_key_exp: 'AQAB'
proof_key_old_mod: 'u/ppb/da4jeKQ+XzKr69VJTqR7wgQp2jzDIaEPQVzfwod+pc1zvO7cwjNgfzF/KQGkltoOi9KdtMzR0qmX8C5wZI6wGpS8S4pTFAZPhXg5w4EpyR8fAagrnlOgaVLs0oX5UuBqKndCQyM7Vj5nFd+r53giS0ch7zDW0uB1G+ZWqTZ1TwbtV6dmlpVuJYeIPonOJgo2iuh455KuS2gvxZKOKR27Uq7W949oM8sqRjvfaVf4xDmyor++98XX0zadnf4pMWfPr3XE+bCXtB9jIPAxxMrALf5ncNRhnx0Wyf8zfM7Rfq+omp/HxCgusF5MC2/Ffnn7me/628zzioAMy5pQ=='
proof_key_old_exp: 'AQAB'

View file

@ -1,9 +0,0 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
user_id:
zip_file:
two:
user_id:
zip_file:

View file

View file

@ -1,76 +0,0 @@
module ArchivableModelTestHelper
def assert_archived_present(obj)
assert_not obj.archived.nil?, "Archived attribute must be present."
end
def assert_active_is_inverse_of_archived(obj)
assert_archived_present(obj)
assert obj.archived? == !obj.active?, "Active attribute isn't inverse of archived attribute."
end
# A new object should be provided (one that
# has never been archived/restored before, but is
# otherwise valid).
def archive_and_restore_action_test(obj, user)
# Check initial values
assert obj.archived? == false, "New (never archived) #{obj.class}'s archived attribute is not set to 'false' by default."
assert obj.archived_on.blank?, "New (never archived) #{obj.class}'s archived_on attribute is not blank."
assert obj.archived_by.blank?, "New (never archived) #{obj.class}'s archived_by attribute is not blank."
assert_restored_on_blank(obj)
assert_restored_by_blank(obj)
# Now, archive the project
ts = Time.now
sleep 1
if user.present?
obj.archive(user)
assert obj.archived_by.present?, "#{obj.class}'s archive action didn't set the archived_by attribute."
else
obj.archive
end
assert obj.archived? == true, "#{obj.class}'s archive action didn't archive it."
assert (
obj.archived_on.present? and
obj.archived_on > ts and
(obj.archived_on - ts) < 5.seconds
), "#{obj.class}'s archive action didn't set archived_on timestamp properly."
# Make sure restored values are still blank
assert_restored_on_blank(obj)
assert_restored_by_blank(obj)
archived_on_ts = obj.archived_on
archived_by_user = obj.archived_by
# Alright, restore the object now
ts = Time.now
sleep 1
if user.present?
obj.restore(user)
assert obj.restored_by.present?, "#{obj.class}'s restore action didn't set the restored_by attribute."
else
obj.restore
end
assert obj.archived? == false, "#{obj.class}'s restore action didn't restore it."
assert (
obj.restored_on.present? and
obj.restored_on > ts and
(obj.restored_on - ts) < 5.seconds
), "#{obj.class}'s restore action didn't set restored_on timestamp properly."
assert archived_on_ts == obj.archived_on, "#{obj.class}'s restore action changed its archived_on timestamp."
assert archived_by_user == obj.archived_by, "#{obj.class}'s restore action' changed its archived_by attribute."
end
private
def assert_restored_on_blank(obj)
assert obj.restored_on.blank?, "New (never restored) #{obj.class}'s restored_on attribute is not blank."
end
def assert_restored_by_blank(obj)
assert obj.restored_by.blank?, "New (never restored) #{obj.class}'s restored_by attribute is not blank."
end
end

View file

@ -1,62 +0,0 @@
module FakeTestHelper
# Generates random CSV file - used for testing purposes
def generate_csvfile
file = Tempfile.open("test", Rails.root.join("tmp"))
begin
(1..10).each do |i|
(1..10).each do |k|
file.write(rand(50..100).to_s + ",")
end
file.write("\n")
end
ensure
file.close
end
file.open
end
# Generates File of size size_in_mb and returns fd
def generate_file(size_in_mb)
require 'securerandom'
one_megabyte = 2 ** 20
randString = SecureRandom.random_bytes(size_in_mb * one_megabyte)
file = Tempfile.open("asset_test", Rails.root.join("tmp"))
file.binmode
file.write(randString)
file.close
file.open
end
def generate_table_contents(rows, cols)
res = []
if rows > 0
res << (1..cols).map{ Faker::Team.state }.to_a
for _ in 2..rows
res << (1..cols).map{ rand * 1000 }.to_a
end
end
return { data: res }.to_json
end
def generate_color
res = "#"
for _ in 1..6
res << "0123456789ABCDEF"[rand(0..15)]
end
res
end
# Game of Thrones name generator v0.2 in all its glory!
# Generate your favourite Westerosi characters with a single
# line of code!
def generate_got_name
GAME_OF_THRONES_NAMES.sample
end
private
GAME_OF_THRONES_NAMES = ["Tyrion Lannister", "Cersei Lannister", "Daenerys Targaryen", "Arya Stark", "Jon Snow", "Sansa Stark", "Jorah Mormont", "Jaime Lannister", "Sandor Clegan", "Tywin lannister", "Theon Greyjoy", "Samwell Tarly", "Joffrey Baratheon", "Catelyn Stark", "Bran Stark", "Petyr Baelish", "Varys", "Robb Stark", "Brienne of Tarth", "Bronn", "Shae", "Gendry", "Ygritte", "Margaery Tyrell", "Stannis Baratheon", "Missandei", "Davos Seaworth", "Melisandre", "Gilly", "Tormund Giantsbane", "Jeor Mormont", "Talisa Stark", "Eddard Stark", "Khal Drogo", "Ramsay Bolton", "Robert Baratheon", "Daario Naharis", "Viserys Targaryen", "Olenna Tyrell", "Maester Luwin", "Mance Rayder", "Oberyn Martell", "Ellaria Sand", "Gregor Clegane", "Walder Frey", "Robin Arryn", "Lysa Arryn", "Tommen Baratheon", "Myrcella Baratheon", "Renly Baratheon", "Salladhor Saan", "Roose Bolton", "Ramsay Bolton", "Balon Greyjoy", "Yara Greyjoy", "Kevan Lannister", "Lancel Lannister", "Polliver", "Amory Lorch", "Doran Martell", "Trystane Martell", "Areo Hotah", "Nymeria Sand", "Obara Sand", "Tyene Sand", "Rickon Stark", "Hodor", "Meera Reed", "Jojen Reed", "Osha", "Rodrik Cassel", "Jory Cassel", "Old Nan", "Jon Umber", "Barristan Selmy", "Grey Worm", "Edmure Tully", "Brynden Tully", "Loras Tyrell", "Mace Tyrell", "Maester Aemon", "Alliser Thorne", "Janos Slynt", "Grenn", "Pyp", "Yoren", "Qhorin Halfhand", "Benjen Stark", "Illyrio Mopatis", "Podrick Payne", "Jaqen H'ghar", "Beric Dondarrion", "Thoros of Myr", "Syrio Forel", "Grand Maester Pycelle", "Qyburn", "Meryn Trant", "The High Septon", "Dontos Hollard", "Ilyn Payne", "Craster", "Grey Wind", "Ghost", "Lady", "Nymeria", "Summer", "Shaggydog", "Balerion", "Meraxes", "Vhagar", "Drogon", "Rhaegal", "Viserion"]
end

View file

@ -1,33 +0,0 @@
module SearchableModelTestHelper
def attributes_like_test(clazz, attributes, query)
if attributes.blank? or query.blank?
attrs = []
elsif attributes.is_a? Symbol
attrs = [attributes.to_s]
elsif attributes.is_a? String
attrs = [attributes]
elsif attributes.is_a? Array
attrs = attributes.collect { |a| a.to_s }
else
raise ArgumentError, ":attributes must be an array, symbol or string"
end
results = clazz.all.where_attributes_like(attrs, query)
unless results.blank?
equery = "#{query.downcase}"
results.each do |result|
cntr = 0
attrs.each do |attr|
val = eval("result.#{attr}").downcase
if (val =~ /.*#{equery}.*/) then
cntr += 1
end
end
assert cntr > 0, "Not all attributes are matching"
end
end
end
end

View file

View file

@ -1,255 +0,0 @@
require 'test_helper'
class CanvasUpdateTest < ActionDispatch::IntegrationTest
def setup
# Preload user
@user = users(:steve)
@password = "hidden_password"
# Preload project
@experiment = experiments(:philadelphia)
# Initialize empty params
@connections = (
@experiment.my_modules
.select { |m| m.active? }
.collect { |m| m.outputs.collect { |c| "#{c.from.id},#{c.to.id}" } }
).flatten.join(",")
@positions = (
@experiment.my_modules
.select { |m| m.active? }
.collect { |m| "#{m.id},#{m.x},#{m.y}" }
).join(";")
@add = ""
@add_names = ""
@rename = "{}"
@cloned = ""
@remove = ""
@module_groups = "{}"
# Sign in as user first
sign_in @user, @password
end
test "should pass without arguments" do
skip('pending............ must implement new routes first')
error = false
begin
post_via_redirect canvas_project_url(@project)
rescue Exception
error = true
end
assert_not error
end
test "should pass with valid arguments" do
skip('pending............ must implement new routes first')
post canvas_project_url(@project),
connections: @connections,
positions: @positions,
add: @add,
"add-names" => @add_names,
rename: @rename,
cloned: @cloned,
remove: @remove,
"module-groups" => @module_groups
assert_redirected_to canvas_project_url(@project)
end
test "should not pass with invalid project id" do
skip('pending............ must implement new routes first')
post_via_redirect canvas_project_url(-5)
assert_redirected_to_404
end
test "should not pass with invalid connections" do
skip('pending............ must implement new routes first')
m1 = my_modules(:qpcr).id
m2 = my_modules(:no_group).id
invalid_connections = [
"1,2,3", # Not dividable by 2
"kkj44gk", # Invalid string
2015, # Number, not dividable by 2
"#{m1},#{m2},#{m2},#{m1}" # Cycle
]
invalid_connections.each do |conn|
post_via_redirect canvas_project_url(@project),
connections: conn,
positions: @positions,
add: @add,
"add-names" => @add_names,
rename: @rename,
cloned: @cloned,
remove: @remove,
"module-groups" => @module_groups
assert_redirected_to_403
end
end
test "should not pass with invalid positions" do
skip('pending............ must implement new routes first')
invalid_positions = [
"fkgdfgfd",
"dsfldkfsd;ldfkdsl;asdsa", # Subtsrings not divided by commas
"a,b,c,d;1,2,3,4", # Substrings have lenghts of 4
"m1,2,a;m2,b,3", # Position is not an integer
"m1,1,2;m2,1,2;m3,2,2" # Multiple modules cannot have same position
]
invalid_positions.each do |pos|
post_via_redirect canvas_project_url(@project),
connections: @connections,
positions: pos,
add: @add,
"add-names" => @add_names,
rename: @rename,
cloned: @cloned,
remove: @remove,
"module-groups" => @module_groups
assert_redirected_to_403
end
end
test "should not pass with invalid add strings" do
skip('pending............ must implement new routes first')
invalid_positions = [
"", # No positions provided
"m1,0,1;m2,4,5", # Invalid module names (too short)
"m1,0,1;m2,4,5" # Names.length != Ids.length
]
invalid_adds = [
"m1,m2", # No positions provided
"m1,m2", # Invalid module names (too short)
"m1,m2" # Names.length != Ids.length
]
invalid_names = [
"module1,module2", # No positions provided
"a,b", # Invalid module names (too short)
"module1,module2,module3" # Names.length != Ids.length
]
invalid_adds.zip(invalid_names).each_with_index do |val, i|
pos = @positions + ";" + invalid_positions[i]
post_via_redirect canvas_project_url(@project),
connections: @connections,
positions: pos,
add: val[0],
"add-names" => val[1],
rename: @rename,
cloned: @cloned,
remove: @remove,
"module-groups" => @module_groups
assert_redirected_to_403
end
end
test "should not pass with invalid rename strings" do
skip('pending............ must implement new routes first')
invalid_renames = [
"asdkjkasd asd",
"'m1':'abule'",
"{15:'aa', 'ac': 23}",
"[]",
]
invalid_renames.each do |val|
post_via_redirect canvas_project_url(@project),
connections: @connections,
positions: @positions,
add: @adds,
"add-names" => @add_names,
rename: val,
cloned: @cloned,
remove: @remove,
"module-groups" => @module_groups
assert_redirected_to_403
end
end
test "should not pass with invalid clone strings" do
skip('pending............ must implement new routes first')
positions = "m1,0,1;m2,4,5"
adds = "m1,m2"
names = "module1|module2"
invalid_clones = [
"kgjfdklg;123;aa2", # Invalid strings
"5k6,m1;zulu,m2", # Invalid source module
"133,m3;233,m4" # Cloned IDs not present in add string
]
invalid_clones.each do |val|
post_via_redirect canvas_project_url(@project),
connections: @connections,
positions: positions,
add: adds,
"add-names" => names,
rename: @rename,
cloned: val,
remove: @remove,
"module-groups" => @module_groups
assert_redirected_to_403
end
end
test "should not pass with invalid remove strings" do
skip('pending............ must implement new routes first')
invalid_removes = [
"a,b,c" # Non-integers
]
invalid_removes.each do |remove|
post_via_redirect canvas_project_url(@project),
connections: @connections,
positions: @positions,
add: @add,
"add-names" => @add_names,
rename: @rename,
cloned: @cloned,
remove: remove,
"module-groups" => @module_groups
assert_redirected_to_403
end
end
test "should not pass with invalid module group strings" do
skip('pending............ must implement new routes first')
invalid_module_groups = [
"asdkjkasd asd",
"'m1':'abule'",
"{15:'aa', 'ac': 23}",
"[]",
]
invalid_module_groups.each do |val|
post_via_redirect canvas_project_url(@project),
connections: @connections,
positions: @positions,
add: @adds,
"add-names" => @add_names,
rename: @rename,
cloned: @cloned,
remove: @remove,
"module-groups" => val
assert_redirected_to_403
end
end
private
# Alas, Devise test helpers don't work in integration tests,
# so this is a "manual" login
def sign_in(user, password)
post_via_redirect user_session_url, "user[email]" => user.email, "user[password]" => password
end
end

View file

View file

@ -1,41 +0,0 @@
require 'test_helper'
class ActivityTest < ActiveSupport::TestCase
test "should validate with correct data" do
activity = Activity.new(
type_of: 0,
project: projects(:interfaces),
my_module: my_modules(:sample_prep),
user: users(:steve)
)
assert activity.valid?
end
test "should not validate without type_of" do
activity = Activity.new(
project: projects(:interfaces),
my_module: my_modules(:sample_prep),
user: users(:steve)
)
assert_not activity.valid?
end
test "should not validate with non existent project" do
activity = Activity.new(
type_of: 0,
project_id: 1212,
user: users(:steve)
)
assert_not activity.valid?
end
test "should not validate with non existent user" do
activity = Activity.new(
type_of: 0,
project: projects(:interfaces),
my_module: my_modules(:sample_prep),
user_id: 123213123
)
assert_not activity.valid?
end
end

View file

@ -1,90 +0,0 @@
require 'test_helper'
require 'helpers/searchable_model_test_helper'
require 'helpers/fake_test_helper'
class AssetTest < ActiveSupport::TestCase
include SearchableModelTestHelper
include FakeTestHelper
def setup
@user = users(:nora)
@step = Step.create(
name: "Step test",
position: 0,
completed: 0,
user: @user,
protocol: protocols(:rna_test_protocol))
@result = Result.create(
name: "Result test",
user: @user,
my_module: my_modules(:list_of_samples),
asset: assets(:one)
)
@comment = Comment.create(
message: "random comment",
user: @user)
@asset = Asset.new(file: generate_csvfile)
end
def teardown
@asset.file = nil
if @asset.persisted? then
@asset.save
@asset.destroy
end
end
test "should not validate with step and result present" do
@asset.step = @step
@asset.result = @result
assert_not @asset.valid?
end
test "should not validate without step and result present" do
skip # Omit due to GUI problems (see asset.rb)
assert @asset.result.blank?
assert @asset.step.blank?
assert_not @asset.valid?
end
test "should not validate without estimated_size present" do
@asset.step = @step
@asset.estimated_size = nil
assert @asset.invalid?
end
test "estimated size defaults to 0" do
asset = Asset.new
assert 0, asset.estimated_size
end
test "should validate with only step present" do
assert @asset.result.blank?
@asset.step = @step
assert @asset.valid?
end
test "should validate with only result present" do
assert @asset.step.blank?
@asset.result = @result
assert @asset.valid?
end
test "should not allow files larger than 50MB" do
asset = Asset.new(file: generate_file(51))
asset.step = @step
assert asset.invalid?
end
test "should allow files < 50MB" do
asset = Asset.new(file: generate_file(49))
asset.step = @step
assert asset.valid?
end
test "where_attributes_like should work" do
attributes_like_test(Asset, :file_file_name, "file")
end
end

View file

@ -1,26 +0,0 @@
require 'test_helper'
class AssetTextDatumTest < ActiveSupport::TestCase
def setup
@asset_data = asset_text_datum(:one)
end
test "should validate with valid data" do
skip
assert @asset_data.valid?
end
test "should check if data is present" do
skip
@asset_data.data = ""
assert_not @assert_data.valid?
@asset_data.data = nil
assert_not @assert_data.valid?
end
test "should check if associated asset is valid" do
skip
assert_not asset_text_datum(:invalid_asset_id)
assert_not asset_text_datum(:invalid_asset_value)
end
end

View file

@ -1,43 +0,0 @@
require 'test_helper'
class ChecklistItemTest < ActiveSupport::TestCase
should validate_presence_of(:text)
should validate_length_of(:text)
.is_at_most(Constants::TEXT_MAX_LENGTH)
test "should validate with correct data" do
chkItem = ChecklistItem.new(
text: "test",
checked: false,
checklist: checklists(:one)
)
assert chkItem.valid?
end
test "should not validate without checked value" do
chkItem = ChecklistItem.new(
text: "text", checked: nil,
checklist: checklists(:one))
assert_not chkItem.valid?, "Checklist item was created without checked value."
end
test "should not validate with non existent checklist" do
chkItem = ChecklistItem.new(
text: "text", checked: false,
checklist_id: 1231234121)
assert_not chkItem.valid?, "Checklist item was created with checklist which doesn't exist."
end
test "should have association checklist <-> checklist item" do
checklist = Checklist.create(
name: "Checklist 17",
step: steps(:step1))
item = ChecklistItem.create(
text: "text", checked: false,
checklist: checklist)
checklist.checklist_items << item
assert_equal item, Checklist.find(checklist.id).checklist_items.first, "No association checklist -> checklist item."
assert_equal checklist, ChecklistItem.find(item.id).checklist, "No association checklist item -> checklist."
end
end

View file

@ -1,28 +0,0 @@
require 'test_helper'
class ChecklistTest < ActiveSupport::TestCase
should validate_presence_of(:step)
should validate_presence_of(:name)
should validate_length_of(:name).is_at_most(Constants::TEXT_MAX_LENGTH)
test "should validate with correct data" do
checklist = Checklist.new(
name: "test",
step: steps(:step1)
)
assert checklist
end
test "should have association step -> checklist" do
checklist = Checklist.new(
name: "test",
step: steps(:step1))
step = Step.create(name: "Step test", position: 0, completed: 0, user: users(:steve), protocol: protocols(:rna_test_protocol))
assert_empty step.checklists
step.checklists << checklist
assert_equal checklist, Step.find(step.id).checklists.first
end
end

View file

@ -1,60 +0,0 @@
require 'test_helper'
class CommentTest < ActiveSupport::TestCase
def setup
@valid = Comment.new(
message: "test",
user: users(:steve),
)
ResultComment.new(
result: results(:one),
comment: @valid
)
end
should validate_presence_of(:message)
should validate_length_of(:message).is_at_most(Constants::TEXT_MAX_LENGTH)
test "should validate" do
assert @valid.valid?
end
test "should not validate with empty user_id" do
comment = Comment.new(message: "Message")
assert_not comment.valid?, "Comment was created with empty user_id."
end
test "should not validate with non existent user" do
comment = Comment.new(message: "comment", user_id: 123123)
assert_not comment.valid?, "Comment was created with user who doesn't exist."
end
test "should not validate with more than one assigned object" do
StepComment.new(
step: steps(:step1),
comment: @valid
)
ResultComment.new(
result: results(:one),
comment: @valid
)
assert_not @valid.valid?, "Comment was valid with more than one assigned object."
end
test "should not validate with no assigned object" do
skip # Omit due to GUI problems (see comment.rb)
@valid.step_comment = nil
@valid.my_module_comment = nil
@valid.result_comment = nil
@valid.sample_comment = nil
@valid.project_comment = nil
assert_not @valid.valid?, "Comment was valid despite having no assigned object."
end
test "should have association comment -> user" do
user = users(:jlaw)
comment = Comment.create(message: "comment", user: user)
assert_equal user, Comment.find(comment.id).user
end
end

View file

@ -1,5 +0,0 @@
require 'test_helper'
class ConnectionTest < ActiveSupport::TestCase
# Nothing to test 8)
end

View file

@ -1,35 +0,0 @@
require 'test_helper'
class CustomFieldTest < ActiveSupport::TestCase
def setup
@custom_field = custom_fields(:volume)
end
should validate_presence_of(:name)
should validate_length_of(:name).is_at_most(Constants::NAME_MAX_LENGTH)
should validate_exclusion_of(:name)
.in_array(['Assigned',
'Sample name',
'Sample type',
'Sample group',
'Added on',
'Added by'])
test 'should validate with correct data' do
assert @custom_field.valid?
end
test 'should not validate with non existent user' do
@custom_field.user_id = 11231231
assert_not @custom_field.valid?
@custom_field.user = nil
assert_not @custom_field.valid?
end
test 'should not validate with non existent team' do
@custom_field.team_id = 1231231
assert_not @custom_field.valid?
@custom_field.team = nil
assert_not @custom_field.valid?
end
end

View file

@ -1,35 +0,0 @@
require 'test_helper'
require 'helpers/archivable_model_test_helper'
require 'helpers/searchable_model_test_helper'
class ExperimentTest < ActiveSupport::TestCase
should validate_length_of(:name)
.is_at_least(Constants::NAME_MIN_LENGTH)
.is_at_most(Constants::NAME_MAX_LENGTH)
should validate_presence_of(:project)
should validate_presence_of(:created_by)
should validate_presence_of(:last_modified_by)
should validate_length_of(:description)
.is_at_most(Constants::TEXT_MAX_LENGTH)
should have_db_column(:name).of_type(:string)
should have_db_column(:description).of_type(:text)
should have_db_column(:project_id).of_type(:integer)
should have_db_column(:created_by_id).of_type(:integer)
should have_db_column(:last_modified_by_id).of_type(:integer)
should have_db_column(:archived).of_type(:boolean)
should have_db_column(:archived_by_id).of_type(:integer)
should have_db_column(:archived_on).of_type(:datetime)
should have_db_column(:restored_by_id).of_type(:integer)
should have_db_column(:restored_on).of_type(:datetime)
should have_db_column(:created_at).of_type(:datetime)
should have_db_column(:updated_at).of_type(:datetime)
should belong_to(:project)
should belong_to(:created_by)
should belong_to(:last_modified_by)
should belong_to(:archived_by)
should belong_to(:restored_by)
should have_many(:my_modules)
should have_many(:my_module_groups)
end

View file

@ -1,39 +0,0 @@
require 'test_helper'
class MyModuleCommentTest < ActiveSupport::TestCase
def setup
@module_comment = my_module_comments(:test)
@my_module = @module_comment.my_module
@comment = @module_comment.comment
end
test "should validate with correct data" do
assert @module_comment.valid?
end
test "should not validate with non existent comment id" do
@module_comment.comment_id = 2343434
assert_not @module_comment.valid?
@module_comment.comment = nil
assert_not @module_comment.valid?
end
test "should not validate with non existent module id" do
@module_comment.my_module_id = 1223232323
assert_not @module_comment.valid?
@module_comment.my_module = nil
assert_not @module_comment.valid?
end
test "should check module/comment uniqueness" do
module_comment = MyModuleComment.new(
my_module: @my_module, comment: @comment)
assert_not module_comment.save
end
test "should have association my_module -> comment" do
@my_module.comments << comments(:unassociated)
assert_equal @comment, MyModule.find(@my_module.id).comments.first,
"There is no association between my_module -> comment."
end
end

View file

@ -1,14 +0,0 @@
require 'test_helper'
require 'helpers/searchable_model_test_helper'
class MyModuleGroupTest < ActiveSupport::TestCase
include SearchableModelTestHelper
def setup
@module_group = my_module_groups(:wf1)
end
test "should validate with valid data" do
assert @module_group.valid?
end
end

View file

@ -1,42 +0,0 @@
require 'test_helper'
class MyModuleTagTest < ActiveSupport::TestCase
def setup
@my_module = my_modules(:qpcr)
@tag = tags(:todo)
@module_tag = MyModuleTag.new(
my_module: @my_module, tag: @tag)
assert @module_tag.save
end
test "should validate with correct data" do
assert @module_tag.valid?
end
test "should not validate with non existent tag id" do
@module_tag.tag_id = 2343434
assert_not @module_tag.valid?
@module_tag.tag = nil
assert_not @module_tag.valid?
end
test "should not validate with non existent module id" do
@module_tag.my_module_id = 1223232323
assert_not @module_tag.valid?
@module_tag.my_module = nil
assert_not @module_tag.valid?
end
test "should check module/tag uniqueness" do
module_tag = MyModuleTag.new(
my_module: @my_module, tag: @tag)
assert_not module_tag.save
end
test "should have association my_module -> tag" do
tag = tags(:urgent)
@my_module.tags << tag
assert_equal tag, MyModule.find(@my_module.id).tags.last,
"There is no association between my_module -> tag."
end
end

View file

@ -1,144 +0,0 @@
require 'test_helper'
require 'helpers/archivable_model_test_helper'
require 'helpers/searchable_model_test_helper'
class MyModuleTest < ActiveSupport::TestCase
include ArchivableModelTestHelper
include SearchableModelTestHelper
def setup
@my_module = my_modules(:list_of_samples)
end
should validate_length_of(:name)
.is_at_least(Constants::NAME_MIN_LENGTH)
.is_at_most(Constants::NAME_MAX_LENGTH)
test "should validate valid module object" do
assert @my_module.valid?
end
test "should not validate without name" do
@my_module.name = ""
assert_not @my_module.valid?
@my_module.name = nil
assert_not @my_module.valid?
end
test "should not validate with non existing experiment" do
@my_module.experiment_id = 123123
assert_not @my_module.valid?
@my_module.experiment = nil
assert_not @my_module.valid?
end
test "should not validate with non existing module group, when group is set" do
@my_module.my_module_group_id = 23123
assert_not @my_module.valid?
end
test "should default to 0, when x and y not set" do
assert_equal 0, @my_module.x
assert_equal 0, @my_module.y
end
test "should default to 0, when workflow_order not set" do
assert_equal 0, @my_module.workflow_order
end
test "should have archived set" do
assert_archived_present(@my_module)
assert_active_is_inverse_of_archived(@my_module)
end
test "archiving should work" do
user = users(:steve)
archive_and_restore_action_test(@my_module, user)
end
test "where_attributes_like should work" do
attributes_like_test(MyModule, [:name, :description], "sample")
end
test "should get unassigned users" do
unassigned_users = @my_module.unassigned_users
assert_equal 1, unassigned_users.size
@my_module.users << unassigned_users.first
assert @my_module.save
unassigned_users = @my_module.unassigned_users
assert_equal 0, unassigned_users.size
end
test "should get unassigned samples" do
unassigned_samples = @my_module.unassigned_samples
assert_equal 5, unassigned_samples.size
@my_module.samples << unassigned_samples.first
assert @my_module.save
unassigned_samples = @my_module.unassigned_samples
assert_equal 4, unassigned_samples.size
end
test "should get unassigned tags" do
unassigned_tags = @my_module.unassigned_tags
assert_equal 2, unassigned_tags.size
@my_module.tags << unassigned_tags.first
assert @my_module.save
unassigned_tags = @my_module.unassigned_tags
assert_equal 1, unassigned_tags.size
end
test "should get last comments" do
skip
end
test "should get last activities" do
skip
end
test "should get specified number of samples" do
skip
end
test "should get completed steps" do
skip
end
test "should check if project is overdue" do
assert @my_module.is_overdue?
@my_module.due_date = "2025-12-04 12:00:00"
assert_not @my_module.is_overdue?
end
test "should check if overdue in days" do
days_diff = 12
@my_module.due_date = DateTime.now - days_diff
assert_equal days_diff, @my_module.overdue_for_days
end
test "should check if is due date one day prior" do
@my_module.due_date = DateTime.now + 1.hour
assert @my_module.is_one_day_prior?
end
test "should check if due date is due in specified days" do
@my_module.due_date = DateTime.now + 1.hour
assert @my_module.is_due_in?(DateTime.now, 2.hours)
end
test "should get archived results" do
archived_results = @my_module.archived_results
assert_equal 1, archived_results.size
end
test "should get downstream modules" do
skip
end
test "should get samples in JSON format" do
skip
end
test "should deep clone module" do
skip
end
end

View file

@ -1,14 +0,0 @@
require 'test_helper'
class NotificationTest < ActiveSupport::TestCase
should have_db_column(:title).of_type(:string)
should have_db_column(:message).of_type(:string)
should have_db_column(:type_of).of_type(:integer)
should have_db_column(:created_at).of_type(:datetime)
should have_db_column(:updated_at).of_type(:datetime)
should have_db_column(:generator_user_id)
should have_many(:user_notifications)
should have_many(:users)
should belong_to(:generator_user).class_name('User')
end

View file

@ -1,39 +0,0 @@
require 'test_helper'
class ProjectCommentTest < ActiveSupport::TestCase
def setup
@project_comment = project_comments(:test)
@project = @project_comment.project
@comment = @project_comment.comment
end
test "should validate with correct data" do
assert @project_comment.valid?
end
test "should not validate with non existent comment id" do
@project_comment.comment_id = 2343434
assert_not @project_comment.valid?
@project_comment.comment = nil
assert_not @project_comment.valid?
end
test "should not validate with non existent project id" do
@project_comment.project_id = 1223232323
assert_not @project_comment.valid?
@project_comment.project = nil
assert_not @project_comment.valid?
end
test "should validate for project/comment uniqueness" do
project_comment = ProjectComment.new(
project: @project, comment: @comment)
assert_not project_comment.save
end
test "should have association project -> comment" do
project = projects(:dummy)
project.comments << @comment
assert_equal @comment, Project.find(project.id).comments.first, "There is no association between project -> comment."
end
end

View file

@ -1,74 +0,0 @@
require 'test_helper'
require 'helpers/archivable_model_test_helper'
require 'helpers/searchable_model_test_helper'
class ProjectTest < ActiveSupport::TestCase
include ArchivableModelTestHelper
include SearchableModelTestHelper
def setup
@project = projects(:test1)
@project2 = projects(:test2)
@project3 = projects(:test3)
end
should validate_length_of(:name)
.is_at_least(Constants::NAME_MIN_LENGTH)
.is_at_most(Constants::NAME_MAX_LENGTH)
test 'should have non-blank name' do
@project.name = ''
assert @project.invalid?, 'Project with blank name returns valid? = true'
end
test 'should have team-wide unique name' do
@project.name = @project2.name
assert @project.invalid?,
'Project with non-unique team-wide name returns valid? = true'
end
test 'should not have non-team-wide unique name' do
@project.name = @project3.name
assert @project.valid?,
'Project with non-unique name in different teams ' \
'returns valid? = false'
end
test 'should have default visibility & archived' do
project = Project.new(name: 'sample project',
team_id: teams(:biosistemika).id)
assert project.hidden?,
'Project by default doesn\'t have visibility = hidden set'
assert_not project.archived?, 'Project has default archived = true'
end
test 'should belong to team' do
@project.team = nil
assert_not @project.valid?, 'Project without team returns valid? = true'
@project.team_id = 12321321
assert_not @project.valid?, 'Project with team returls valid? = false'
end
test 'should have archived set' do
project = Project.new(
name: 'test project',
visibility: 1,
team_id: teams(:biosistemika).id
)
assert_archived_present(project)
assert_active_is_inverse_of_archived(project)
end
test 'archiving should work' do
user = users(:steve)
project = Project.new(name: 'test project',
visibility: 1,
team_id: teams(:biosistemika).id)
project.save
archive_and_restore_action_test(project, user)
end
test 'where_attributes_like should work' do
attributes_like_test(Project, :name, 'star')
end
end

View file

@ -1,11 +0,0 @@
require 'test_helper'
class ProtocolKeywordTest < ActiveSupport::TestCase
def setup
@kw = protocol_keywords(:kw1)
end
should validate_presence_of(:name)
should validate_length_of(:name).is_at_most(Constants::NAME_MAX_LENGTH)
end

View file

@ -1,162 +0,0 @@
require 'test_helper'
class ProtocolTest < ActiveSupport::TestCase
def setup
@user = users(:steve)
@team = teams(:biosistemika)
@my_module = my_modules(:sample_prep)
@global = protocols(:rna_test_protocol_global)
@p = Protocol.new(
my_module: @my_module,
team: @team
)
end
should validate_length_of(:name).is_at_most(Constants::NAME_MAX_LENGTH)
should validate_length_of(:description).is_at_most(Constants::TEXT_MAX_LENGTH)
test 'protocol_type enum works' do
@p.protocol_type = :unlinked
assert @p.in_module?
@p.protocol_type = :linked
assert @p.in_module?
@p.protocol_type = :in_repository_private
assert @p.in_repository?
@p.protocol_type = :in_repository_public
assert @p.in_repository?
@p.protocol_type = :in_repository_archived
assert @p.in_repository?
end
test 'should not validate without team' do
@p.team = @team
assert @p.valid?
@p.team = nil
assert_not @p.valid?
end
test 'should not validate without protocol type' do
assert @p.valid?
@p.protocol_type = nil
assert_not @p.valid?
end
test 'should count steps of protocol' do
assert_equal 0, @p.number_of_steps
end
test 'specific validations for :unlinked' do
p = new_unlinked_protocol
assert p.valid?
p.my_module = nil
assert_not p.valid?
end
test 'specific validations for :linked' do
p = new_linked_protocol
assert p.valid?
p.my_module = nil
assert_not p.valid?
p = new_linked_protocol
p.added_by = nil
assert_not p.valid?
p = new_linked_protocol
p.parent = nil
assert_not p.valid?
p = new_linked_protocol
p.parent_updated_at = nil
assert_not p.valid?
end
test 'specific validations for :in_repository' do
[
:in_repository_private,
:in_repository_public,
:in_repository_archived
].each do |protocol_type|
p = new_repository_protocol(protocol_type)
if protocol_type == :in_repository_archived
p.archived_by = @user
p.archived_on = Time.now
elsif protocol_type == :in_repository_public
p.published_on = Time.now
end
assert p.valid?
p.name = nil
assert_not p.valid?
p = new_repository_protocol(protocol_type)
p.added_by = nil
assert_not p.valid?
p = new_repository_protocol(protocol_type)
p.my_module = @my_module
assert_not p.valid?
p = new_repository_protocol(protocol_type)
p.parent = @global
assert_not p.valid?
p = new_repository_protocol(protocol_type)
p.parent_updated_at = Time.now
assert_not p.valid?
end
end
test 'specific validations for :in_repository_public' do
p = new_repository_protocol(:in_repository_public)
p.published_on = nil
assert_not p.valid?
p.published_on = Time.now
assert p.valid?
end
test 'specific validations for :in_repository_archived' do
p = new_repository_protocol(:in_repository_archived)
p.archived_by = nil
p.archived_on = nil
assert_not p.valid?
p.archived_by = @user
assert_not p.valid?
p.archived_on = Time.now
assert p.valid?
end
private
def new_unlinked_protocol
Protocol.new(
my_module: @my_module,
team: @team
)
end
def new_linked_protocol
Protocol.new(
protocol_type: :linked,
my_module: @my_module,
team: @team,
added_by: @user,
parent: @global,
parent_updated_at: @global.updated_at
)
end
def new_repository_protocol(type)
Protocol.new(
name: 'Test protocol',
protocol_type: type,
team: @team,
added_by: @user
)
end
end

View file

@ -1,103 +0,0 @@
require 'test_helper'
class ReportElementTest < ActiveSupport::TestCase
test "should validate with valid data" do
@re = generate_new_el(true)
assert @re.valid?, "Valid report element is not valid"
end
test "should not validate with invalid position" do
@re = generate_new_el(true)
@re.position = nil
assert_not @re.valid?, "Report element without position was valid"
end
test "should not validate without report" do
@re = generate_new_el(true)
@re.report = nil
assert_not @re.valid?, "Report element without report was valid"
@re.report_id = -1
assert_not @re.valid?, "Report element with invalid report reference was valid"
end
test "should not validate without type_of" do
@re = generate_new_el(true)
@re.type_of = nil
assert_not @re.valid?, "Report element without type_of was valid"
end
test "test element references" do
@re = generate_new_el(true)
@re.project = nil
assert_not @re.valid?, "Report without any element reference was valid"
@re.project = projects(:interfaces)
@re.my_module = my_modules(:list_of_samples)
assert_not @re.valid?, "Report with >1 element references was valid"
# Test all types of elements
re_vals_list = [
{ type_of: 0, id: projects(:interfaces).id },
{ type_of: 1, id: my_modules(:list_of_samples).id },
{ type_of: 2, id: steps(:step1).id },
{ type_of: 3, id: results(:two).id, result: true },
{ type_of: 4, id: results(:four).id, result: true },
{ type_of: 5, id: results(:one).id, result: true },
{ type_of: 6, id: my_modules(:list_of_samples).id },
{ type_of: 7, id: my_modules(:list_of_samples).id },
{ type_of: 8, id: checklists(:one).id },
{ type_of: 9, id: assets(:one).id },
{ type_of: 10, id: tables(:one).id },
{ type_of: 11, id: steps(:step1).id, comments: true },
{ type_of: 12, id: results(:one).id, comments: true }
]
re_vals_list.each do |re_vals|
re = generate_new_el(false)
re.type_of = re_vals[:type_of]
re.set_element_reference(re_vals[:id])
assert re.valid?
assert_equal re_vals[:id], re.element_reference.id
assert re.result? if re_vals.include? :result
assert re.comments? if re_vals.include? :comments
assert_element_reference_present re
end
end
private
def generate_new_el(include_reference)
re = ReportElement.new(
position: 0,
type_of: 0,
sort_order: nil,
report: reports(:one),
project: projects(:interfaces)
)
unless include_reference then
re.project = nil
end
re
end
def assert_element_reference_present(re)
if re.project_header? or re.project_activity? or re.project_samples?
assert re.project.present?
elsif re.my_module? or re.my_module_activity? or re.my_module_samples?
assert re.my_module.present?
elsif re.step? or re.step_comments?
assert re.step.present?
elsif re.result_asset? or re.result_table? or re.result_text? or re.result_comments?
assert re.result.present?
elsif re.step_checklist?
assert re.checklist.present?
elsif re.step_asset?
assert re.asset.present?
elsif re.step_table?
assert re.table.present?
end
end
end

View file

@ -1,100 +0,0 @@
require 'test_helper'
class ReportTest < ActiveSupport::TestCase
def setup
@report = reports(:one)
@json_el = {
"type_of" => "result_comments",
"sort_order" => "desc",
"id" => results(:four).id,
}
end
should validate_length_of(:name)
.is_at_least(Constants::NAME_MIN_LENGTH)
.is_at_most(Constants::NAME_MAX_LENGTH)
should validate_length_of(:description)
.is_at_most(Constants::TEXT_MAX_LENGTH)
test "should validate with valid data" do
assert @report.valid?, "Report with valid data was invalid"
end
test 'should not validate with invalid name' do
# Check if uniqueness constraint works
@report2 = Report.new(
name: @report.name,
project: projects(:interfaces),
user: users(:steve)
)
assert_not @report2.valid?,
'Report with same name for specific user was valid'
end
test "should not validate without project" do
@report.project = nil
assert_not @report.valid?, "Report without project reference was valid"
end
test "should not validate without user" do
@report.user = nil
assert_not @report.valid?, "Report without user reference was valid"
end
test "test root_elements function" do
elements = @report.root_elements
pos = -10000
elements.each do |element|
assert element.position >= pos, "Function root_elements doesn't sort elements properly"
pos = element.position
assert element.parent.blank?, "Function root_elements doesn't return elements without parents"
end
end
test "test save_with_contents function" do
# We shall only test if saving fails for sinigle json element variants
# (saving of report itself was handled in previous tests).
@report2 = new_valid_report
@json_el2 = @json_el.deep_dup
@json_el2.delete("type_of")
assert_not @report2.save_with_contents([@json_el2]), "Report with invalid json_element (without type_of) was saved"
@report2 = new_valid_report
@json_el2 = @json_el.deep_dup
@json_el2["type_of"] = "tralala"
assert_not @report2.save_with_contents([@json_el2]), "Report with invalid json_element (invalid type_of) was saved"
@report2 = new_valid_report
@json_el2 = @json_el.deep_dup
@json_el2["sort_order"] = "tralala"
assert_not @report2.save_with_contents([@json_el2]), "Report with invalid json_element (invalid sort_order) was saved"
@report2 = new_valid_report
@json_el2 = @json_el.deep_dup
@json_el2.delete("id")
assert_not @report2.save_with_contents([@json_el2]), "Report with invalid json_element (without id) was saved"
@report2 = new_valid_report
@json_el2 = @json_el.deep_dup
@json_el2["id"] = -1
assert_not @report2.save_with_contents([@json_el2]), "Report with invalid json_element (invalid id) was saved"
@report2 = new_valid_report
@json_el2 = @json_el.deep_dup
assert @report2.save_with_contents([@json_el2]), "Report with valid json_element was not saved"
end
private
def new_valid_report
Report.new(
name: "report 2",
project: projects(:interfaces),
user: users(:steve)
)
end
end

View file

@ -1,32 +0,0 @@
require 'test_helper'
require 'helpers/fake_test_helper'
class ResultAssetTest < ActiveSupport::TestCase
include FakeTestHelper
def setup
@result_asset = result_assets(:test)
end
test "should not validate with non existent asset_id" do
@result_asset.asset_id = 1231295
assert_not @result_asset.valid?
@result_asset.asset = nil
assert_not @result_asset.valid?
end
test "should not validate with non existent result_id" do
@result_asset.result_id = 123123
assert_not @result_asset.valid?
@result_asset.result = nil
assert_not @result_asset.valid?
end
test "should have association result -> asset" do
result = results(:two)
asset = Asset.new(file: generate_csvfile)
result.asset = asset
assert result.save
assert_equal asset, Result.find(result.id).asset, "There is no association between result -> asset."
end
end

View file

@ -1,38 +0,0 @@
require 'test_helper'
class ResultCommentTest < ActiveSupport::TestCase
def setup
@result_comment = result_comments(:test)
end
test "should validate with correct data" do
assert @result_comment.valid?
end
test "should not validate with non existent comment id" do
@result_comment.comment_id = 2343434
assert_not @result_comment.valid?
@result_comment.comment = nil
assert_not @result_comment.valid?
end
test "should not validate with non existent result id" do
@result_comment.result_id = 1223232323
assert_not @result_comment.valid?
@result_comment.result = nil
assert_not @result_comment.valid?
end
test "should validate uniqueness" do
result_comment = ResultComment.new(
result: @result_comment.result, comment: @result_comment.comment)
assert_not result_comment.save
end
test "should destroy dependent comments" do
result_comment = result_comments(:one)
assert Comment.find(result_comment.comment_id)
assert result_comment.destroy
assert_not Comment.find_by_id(result_comment.comment_id)
end
end

View file

@ -1,48 +0,0 @@
require 'test_helper'
class ResultTableTest < ActiveSupport::TestCase
def setup
@result_table = result_tables(:test)
end
test "should validate with correct data" do
assert @result_table.valid?
end
test "should not validate with non existent result_id" do
@result_table.result_id = 123123
assert_not @result_table.valid?
@result_table.result = nil
assert_not @result_table.valid?
end
test "should not validate with non existent table_id" do
@result_table.table_id = 12321321
assert_not @result_table.valid?
@result_table.table = nil
assert_not @result_table.valid?
end
test "should have association result -> table" do
result = Result.new(
name: "Result test",
user: users(:steve),
my_module: my_modules(:list_of_samples))
table = tables(:test)
assert_nil result.asset
assert_nil result.table
assert_nil result.result_text
result.table = table
result.save
assert_equal table, Result.find(result.id).table
end
test "should destroy dependent tables" do
result_table = result_tables(:one)
assert Table.find(result_table.table_id)
assert result_table.destroy
assert_not Table.find_by_id(result_table.table_id)
end
end

View file

@ -1,163 +0,0 @@
require 'test_helper'
require 'helpers/archivable_model_test_helper'
require 'helpers/searchable_model_test_helper'
class ResultTest < ActiveSupport::TestCase
include ArchivableModelTestHelper
include SearchableModelTestHelper
def setup
@result = results(:test_result)
end
test "should be valid with correct data" do
assert @result.valid?, @result.errors.messages
end
test "should validate with blank text" do
@result.name = ""
assert @result.valid?
@result.name = " "
assert @result.valid?
@result.name = nil
assert @result.valid?
end
test "should validate name length" do
@result.name *= 50
assert_not @result.valid?
end
test "should not validate with non existent user" do
@result.user_id = 12321321
assert_not @result.valid?
@result.user = nil
assert_not @result.valid?
end
test "should not validate with non existent my_module" do
@result.my_module_id = 1231232
assert_not @result.valid?
@result.my_module = nil
assert_not @result.valid?
end
test "should not validate with having no text, asset nor table" do
result = Result.new(
user: users(:steve),
my_module: my_modules(:sample_prep))
assert_not result.valid?, "Result should not be valid without text, asset nor table set."
end
test "should not validate with being text, asset, table at the same time" do
result = results(:no_items)
result.result_text = result_texts(:one)
assert result.valid?, "Result should be valid with only result_text."
result.asset = assets(:one)
assert_not result.valid? "Result should not be valid with both result_text and asset."
result.table = Table.new(contents: "test")
assert_not result.valid?, "Result should not be valid with all types assigned."
end
test "should validate with only asset present" do
result = results(:no_items)
result.asset = assets(:one)
assert result.valid?
end
test "should have archived set" do
result = results(:no_items)
result.asset = assets(:one)
assert_archived_present(result)
assert_active_is_inverse_of_archived(result)
end
test "archiving should work" do
result = results(:no_items)
result.asset = assets(:one)
result.save
archive_and_restore_action_test(result, result.user)
end
test "where_attributes_like should work" do
attributes_like_test(Result, :name, "text nr. 1")
end
test "should test for asset type of result" do
result = results(:no_items)
assert_not result.is_asset
result.asset = assets(:one)
assert result.is_asset
end
test "should test for table type of result" do
result = results(:no_items)
assert_not result.is_table
result.table = tables(:test)
assert result.is_table
end
test "should test for text type of result" do
result = results(:no_items)
assert_not result.is_text
result.result_text = result_texts(:one)
assert result.is_text
end
test "should get last comments" do
last_comments = results(:test2).last_comments
first_comment = comments(:test_result_comment_24)
last_comment = comments(:test_result_comment_5)
assert_equal 20, last_comments.size
assert_equal first_comment, last_comments.last
assert_equal last_comment, last_comments.first
end
# Not possible to test with fixtures and random id values
test "should get last comments before specific comment" do
skip
end
test "should get last comments of specified length" do
last_comments = results(:test2).last_comments(0, 5)
first_comment = comments(:test_result_comment_24)
last_comment = comments(:test_result_comment_20)
assert_equal 5, last_comments.size
assert_equal first_comment, last_comments.last
assert_equal last_comment, last_comments.first
end
test "should search for results of user" do
skip('pending............ must implement search in Experiment model first')
search_results = Result.search(users(:steve), false)
assert_equal 7, search_results.size
end
test "should search archived results of user" do
skip('pending............ must implement search in Experiment model first')
search_results = Result.search(users(:steve), true)
assert_equal 8, search_results.size
end
test "should search results by name" do
skip('pending............ must implement search in Experiment model first')
search_results = Result.search(users(:steve), false, "table")
assert_equal 1, search_results.size
end
test "should search archived results by name" do
skip('pending............ must implement search in Experiment model first')
search_results = Result.search(users(:steve), true, "table")
assert_equal 2, search_results.size
end
test "should have association result -> comment" do
num_of_comments = @result.comments.size
comment = comments(:one)
@result.comments << comment
assert_equal comment, Result.find(@result.id).comments.last, "There is no association between result -> comment."
assert_equal num_of_comments + 1, @result.comments.size
end
end

View file

@ -1,39 +0,0 @@
require 'test_helper'
class ResultTextTest < ActiveSupport::TestCase
def setup
@result_text = result_texts(:test)
end
test "should validate with correct data" do
assert @result_text.valid?
end
test "should not validate without text" do
@result_text.text = ""
assert_not @result_text.valid?
@result_text.text = nil
assert_not @result_text.valid?
end
test "should not validate with non existent result" do
@result_text.result_id = 1232132
assert_not @result_text.valid?
@result_text.result = nil
assert_not @result_text.valid?
end
test "should have association result -> result_text" do
result = Result.new(
name: "Result test",
user: users(:steve),
my_module: my_modules(:list_of_samples))
result_text = ResultText.new(
text: "test")
assert_nil result.result_text
result.result_text = result_text
result.save
assert_equal result_text, Result.find(result.id).result_text
end
end

Some files were not shown because too many files have changed in this diff Show more