mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-11 23:54:43 +08:00
rename organizations in test/
This commit is contained in:
parent
f04a2f663a
commit
883a6ea544
26 changed files with 355 additions and 356 deletions
|
@ -1,24 +1,24 @@
|
||||||
org_1:
|
team_1:
|
||||||
name: Org1
|
name: Team1
|
||||||
|
|
||||||
org_2:
|
team_2:
|
||||||
name: Org2
|
name: Team2
|
||||||
|
|
||||||
user_1:
|
user_1:
|
||||||
full_name: Usr1
|
full_name: Usr1
|
||||||
email: usr1@gmail.com
|
email: usr1@gmail.com
|
||||||
organizations: org_1, org_2
|
teams: team_1, team_2
|
||||||
password: secretPassword
|
password: secretPassword
|
||||||
|
|
||||||
user_2:
|
user_2:
|
||||||
full_name: Usr2
|
full_name: Usr2
|
||||||
email: usr2@gmail.com
|
email: usr2@gmail.com
|
||||||
organizations: org_1
|
teams: team_1
|
||||||
|
|
||||||
user_3:
|
user_3:
|
||||||
full_name: Usr3
|
full_name: Usr3
|
||||||
email: usr3@gmail.com
|
email: usr3@gmail.com
|
||||||
organizations: org_2
|
teams: team_2
|
||||||
|
|
||||||
user_4:
|
user_4:
|
||||||
full_name: Usr4
|
full_name: Usr4
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class OrganizationsControllerTest < ActionController::TestCase
|
class TeamsControllerTest < ActionController::TestCase
|
||||||
# test "the truth" do
|
# test "the truth" do
|
||||||
# assert true
|
# assert true
|
||||||
# end
|
# end
|
8
test/fixtures/custom_fields.yml
vendored
8
test/fixtures/custom_fields.yml
vendored
|
@ -1,16 +1,14 @@
|
||||||
volume:
|
volume:
|
||||||
name: "Volume"
|
name: "Volume"
|
||||||
user: steve
|
user: steve
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
|
|
||||||
location:
|
location:
|
||||||
name: "Location"
|
name: "Location"
|
||||||
user: jlaw
|
user: jlaw
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
|
|
||||||
description:
|
description:
|
||||||
name: "Description"
|
name: "Description"
|
||||||
user: nora
|
user: nora
|
||||||
organization: nib
|
team: nib
|
||||||
|
|
||||||
|
|
||||||
|
|
5
test/fixtures/logs.yml
vendored
5
test/fixtures/logs.yml
vendored
|
@ -1,8 +1,7 @@
|
||||||
one:
|
one:
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
message: This is a test log numero uno
|
message: This is a test log numero uno
|
||||||
|
|
||||||
two:
|
two:
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
message: This is a test log numero due
|
message: This is a test log numero due
|
||||||
|
|
||||||
|
|
30
test/fixtures/projects.yml
vendored
30
test/fixtures/projects.yml
vendored
|
@ -2,7 +2,7 @@ interfaces:
|
||||||
name: INTERFACES
|
name: INTERFACES
|
||||||
visibility: 1
|
visibility: 1
|
||||||
due_date: 2015-11-02 15:30:22
|
due_date: 2015-11-02 15:30:22
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
archived: false
|
archived: false
|
||||||
archived_on:
|
archived_on:
|
||||||
created_at: 2015-11-01 11:37:26
|
created_at: 2015-11-01 11:37:26
|
||||||
|
@ -16,7 +16,7 @@ eurostars:
|
||||||
name: EUROSTARS
|
name: EUROSTARS
|
||||||
visibility: 1
|
visibility: 1
|
||||||
due_date: 2015-11-02 15:30:22
|
due_date: 2015-11-02 15:30:22
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
archived: false
|
archived: false
|
||||||
archived_on:
|
archived_on:
|
||||||
created_at: 2015-11-01 12:53:07
|
created_at: 2015-11-01 12:53:07
|
||||||
|
@ -30,7 +30,7 @@ krop:
|
||||||
name: KROP 2012
|
name: KROP 2012
|
||||||
visibility: 1
|
visibility: 1
|
||||||
due_date: 2012-05-07 13:30:25
|
due_date: 2012-05-07 13:30:25
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
archived: true
|
archived: true
|
||||||
archived_on: 2012-05-09 16:23:33
|
archived_on: 2012-05-09 16:23:33
|
||||||
created_by: mark
|
created_by: mark
|
||||||
|
@ -43,7 +43,7 @@ phd:
|
||||||
name: PhD Thesis
|
name: PhD Thesis
|
||||||
visibility: 0
|
visibility: 0
|
||||||
due_date:
|
due_date:
|
||||||
organization: nib
|
team: nib
|
||||||
archived: false
|
archived: false
|
||||||
archived_on:
|
archived_on:
|
||||||
created_by: mark
|
created_by: mark
|
||||||
|
@ -56,7 +56,7 @@ decathlon:
|
||||||
name: DECATHLON
|
name: DECATHLON
|
||||||
visibility: 1
|
visibility: 1
|
||||||
due_date:
|
due_date:
|
||||||
organization: phylos
|
team: phylos
|
||||||
archived: false
|
archived: false
|
||||||
archived_on:
|
archived_on:
|
||||||
created_by: jlaw
|
created_by: jlaw
|
||||||
|
@ -69,7 +69,7 @@ valor:
|
||||||
name: VALOR 2010
|
name: VALOR 2010
|
||||||
visibility: 1
|
visibility: 1
|
||||||
due_date: 2010-11-13 14:11:23
|
due_date: 2010-11-13 14:11:23
|
||||||
organization: nib
|
team: nib
|
||||||
archived: false
|
archived: false
|
||||||
archived_on: 2012-05-09 16:33:33
|
archived_on: 2012-05-09 16:33:33
|
||||||
created_by: nora
|
created_by: nora
|
||||||
|
@ -82,7 +82,7 @@ secret:
|
||||||
name: My Secret Life
|
name: My Secret Life
|
||||||
visibility: 0
|
visibility: 0
|
||||||
due_date: 2030-06-04 13:00:00
|
due_date: 2030-06-04 13:00:00
|
||||||
organization: nib
|
team: nib
|
||||||
archived: false
|
archived: false
|
||||||
archived_on:
|
archived_on:
|
||||||
created_by: mark
|
created_by: mark
|
||||||
|
@ -95,7 +95,7 @@ a_project:
|
||||||
name: A Project
|
name: A Project
|
||||||
visibility: 1
|
visibility: 1
|
||||||
due_date: 2018-12-02 15:30:22
|
due_date: 2018-12-02 15:30:22
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
archived: false
|
archived: false
|
||||||
archived_on:
|
archived_on:
|
||||||
created_at: 2015-11-01 14:28:15
|
created_at: 2015-11-01 14:28:15
|
||||||
|
@ -109,7 +109,7 @@ z_project:
|
||||||
name: Z Project
|
name: Z Project
|
||||||
visibility: 1
|
visibility: 1
|
||||||
due_date: 2018-12-02 15:30:22
|
due_date: 2018-12-02 15:30:22
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
archived: false
|
archived: false
|
||||||
archived_on:
|
archived_on:
|
||||||
created_at: 2015-11-01 16:15:37
|
created_at: 2015-11-01 16:15:37
|
||||||
|
@ -123,7 +123,7 @@ a_archived_project:
|
||||||
name: A Archived Project
|
name: A Archived Project
|
||||||
visibility: 1
|
visibility: 1
|
||||||
due_date: 2018-12-02 15:30:22
|
due_date: 2018-12-02 15:30:22
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
archived: true
|
archived: true
|
||||||
archived_on: 2015-11-05 08:14:56
|
archived_on: 2015-11-05 08:14:56
|
||||||
created_at: 2015-11-01 14:28:15
|
created_at: 2015-11-01 14:28:15
|
||||||
|
@ -137,7 +137,7 @@ z_archived_project:
|
||||||
name: Z Archived Project
|
name: Z Archived Project
|
||||||
visibility: 1
|
visibility: 1
|
||||||
due_date: 2018-12-02 15:30:22
|
due_date: 2018-12-02 15:30:22
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
archived: true
|
archived: true
|
||||||
archived_on: 2015-11-05 08:12:56
|
archived_on: 2015-11-05 08:12:56
|
||||||
created_at: 2015-11-01 16:15:37
|
created_at: 2015-11-01 16:15:37
|
||||||
|
@ -151,25 +151,25 @@ test1:
|
||||||
name: Project 1
|
name: Project 1
|
||||||
visibility: 1
|
visibility: 1
|
||||||
due_date: <%= DateTime.now %>
|
due_date: <%= DateTime.now %>
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
archived: false
|
archived: false
|
||||||
created_by: steve
|
created_by: steve
|
||||||
|
|
||||||
test2:
|
test2:
|
||||||
name: Project 2
|
name: Project 2
|
||||||
visibility: 0
|
visibility: 0
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
archived: true
|
archived: true
|
||||||
archived_on: <%= DateTime.now %>
|
archived_on: <%= DateTime.now %>
|
||||||
|
|
||||||
test3:
|
test3:
|
||||||
name: Project 3
|
name: Project 3
|
||||||
visibility: 1
|
visibility: 1
|
||||||
organization: nib
|
team: nib
|
||||||
archived: false
|
archived: false
|
||||||
|
|
||||||
dummy:
|
dummy:
|
||||||
name: Dummy project
|
name: Dummy project
|
||||||
visibility: 1
|
visibility: 1
|
||||||
organization: nib
|
team: nib
|
||||||
archived: false
|
archived: false
|
||||||
|
|
10
test/fixtures/protocol_keywords.yml
vendored
10
test/fixtures/protocol_keywords.yml
vendored
|
@ -1,19 +1,19 @@
|
||||||
kw1:
|
kw1:
|
||||||
name: "qPCR"
|
name: "qPCR"
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
|
|
||||||
kw2:
|
kw2:
|
||||||
name: "Lab"
|
name: "Lab"
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
|
|
||||||
kw3:
|
kw3:
|
||||||
name: "ELISA"
|
name: "ELISA"
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
|
|
||||||
kw4:
|
kw4:
|
||||||
name: "Sample Prep"
|
name: "Sample Prep"
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
|
|
||||||
kw5:
|
kw5:
|
||||||
name: "Vortexing"
|
name: "Vortexing"
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
|
|
8
test/fixtures/protocols.yml
vendored
8
test/fixtures/protocols.yml
vendored
|
@ -4,21 +4,21 @@ rna_test_protocol:
|
||||||
description: "This is a test protocol."
|
description: "This is a test protocol."
|
||||||
added_by: steve
|
added_by: steve
|
||||||
my_module: rna_test
|
my_module: rna_test
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
protocol_type: 1
|
protocol_type: 1
|
||||||
parent: rna_test_protocol_global
|
parent: rna_test_protocol_global
|
||||||
parent_updated_at: "2015-11-06 11:12:00"
|
parent_updated_at: "2015-11-06 11:12:00"
|
||||||
|
|
||||||
sample_prep_protocol:
|
sample_prep_protocol:
|
||||||
my_module: sample_prep
|
my_module: sample_prep
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
protocol_type: 0
|
protocol_type: 0
|
||||||
|
|
||||||
list_of_samples_protocol:
|
list_of_samples_protocol:
|
||||||
name: "List samples"
|
name: "List samples"
|
||||||
description: "This is WIP, don't touch"
|
description: "This is WIP, don't touch"
|
||||||
my_module: list_of_samples
|
my_module: list_of_samples
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
protocol_type: 0
|
protocol_type: 0
|
||||||
|
|
||||||
rna_test_protocol_global:
|
rna_test_protocol_global:
|
||||||
|
@ -26,7 +26,7 @@ rna_test_protocol_global:
|
||||||
authors: "Schmidt, Jurgen"
|
authors: "Schmidt, Jurgen"
|
||||||
description: "This is a test protocol."
|
description: "This is a test protocol."
|
||||||
added_by: steve
|
added_by: steve
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
protocol_type: 3
|
protocol_type: 3
|
||||||
updated_at: "2015-11-06 11:12:00"
|
updated_at: "2015-11-06 11:12:00"
|
||||||
published_on: "2015-11-06 11:12:00"
|
published_on: "2015-11-06 11:12:00"
|
4
test/fixtures/sample_groups.yml
vendored
4
test/fixtures/sample_groups.yml
vendored
|
@ -1,7 +1,7 @@
|
||||||
blood:
|
blood:
|
||||||
name: Blood
|
name: Blood
|
||||||
color: "#ff0000"
|
color: "#ff0000"
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
created_by: steve
|
created_by: steve
|
||||||
last_modified_by: mark
|
last_modified_by: mark
|
||||||
|
|
||||||
|
@ -9,6 +9,6 @@ blood:
|
||||||
noble:
|
noble:
|
||||||
name: Blue blood
|
name: Blue blood
|
||||||
color: "#0000ff"
|
color: "#0000ff"
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
created_by: steve
|
created_by: steve
|
||||||
last_modified_by: steve
|
last_modified_by: steve
|
||||||
|
|
4
test/fixtures/sample_types.yml
vendored
4
test/fixtures/sample_types.yml
vendored
|
@ -1,9 +1,9 @@
|
||||||
skin:
|
skin:
|
||||||
name: Skin
|
name: Skin
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
created_by: steve
|
created_by: steve
|
||||||
|
|
||||||
urine:
|
urine:
|
||||||
name: Urine
|
name: Urine
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
created_by: steve
|
created_by: steve
|
||||||
|
|
10
test/fixtures/samples.yml
vendored
10
test/fixtures/samples.yml
vendored
|
@ -1,7 +1,7 @@
|
||||||
sample1:
|
sample1:
|
||||||
name: Cow DNA
|
name: Cow DNA
|
||||||
user: steve
|
user: steve
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
sample_type: urine
|
sample_type: urine
|
||||||
sample_group: blood
|
sample_group: blood
|
||||||
last_modified_by: steve
|
last_modified_by: steve
|
||||||
|
@ -9,7 +9,7 @@ sample1:
|
||||||
sample2:
|
sample2:
|
||||||
name: Bat DNA
|
name: Bat DNA
|
||||||
user: steve
|
user: steve
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
sample_type: skin
|
sample_type: skin
|
||||||
sample_group: noble
|
sample_group: noble
|
||||||
last_modified_by: steve
|
last_modified_by: steve
|
||||||
|
@ -17,15 +17,15 @@ sample2:
|
||||||
sample3:
|
sample3:
|
||||||
name: Cat DNA
|
name: Cat DNA
|
||||||
user: steve
|
user: steve
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
last_modified_by: jlaw
|
last_modified_by: jlaw
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Test Sample
|
name: Test Sample
|
||||||
user: jlaw
|
user: jlaw
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
|
|
||||||
test2:
|
test2:
|
||||||
name: Another test sample
|
name: Another test sample
|
||||||
user: jlaw
|
user: jlaw
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
|
|
|
@ -12,10 +12,10 @@ phylos:
|
||||||
created_by: steve
|
created_by: steve
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Test Organization
|
name: Test Team
|
||||||
description: "Testing organization, you know"
|
description: "Testing team, you know"
|
||||||
|
|
||||||
steve_org:
|
steve_team:
|
||||||
name: Steve's Organization
|
name: Steve's Team
|
||||||
description: "Private organization"
|
description: "Private team"
|
||||||
created_by: steve
|
created_by: steve
|
|
@ -1,98 +1,98 @@
|
||||||
one:
|
one:
|
||||||
user: steve
|
user: steve
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
role: 1
|
role: 1
|
||||||
assigned_by: steve
|
assigned_by: steve
|
||||||
|
|
||||||
|
|
||||||
two:
|
two:
|
||||||
user: steve
|
user: steve
|
||||||
organization: nib
|
team: nib
|
||||||
role: 1
|
role: 1
|
||||||
assigned_by: steve
|
assigned_by: steve
|
||||||
|
|
||||||
|
|
||||||
seven:
|
seven:
|
||||||
user: steve
|
user: steve
|
||||||
organization: phylos
|
team: phylos
|
||||||
role: 1
|
role: 1
|
||||||
assigned_by: steve
|
assigned_by: steve
|
||||||
|
|
||||||
|
|
||||||
three:
|
three:
|
||||||
user: mark
|
user: mark
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
role: 1
|
role: 1
|
||||||
assigned_by: mark
|
assigned_by: mark
|
||||||
|
|
||||||
|
|
||||||
four:
|
four:
|
||||||
user: mark
|
user: mark
|
||||||
organization: nib
|
team: nib
|
||||||
role: 2
|
role: 2
|
||||||
assigned_by: mark
|
assigned_by: mark
|
||||||
|
|
||||||
|
|
||||||
five:
|
five:
|
||||||
user: jlaw
|
user: jlaw
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
role: 0
|
role: 0
|
||||||
assigned_by: steve
|
assigned_by: steve
|
||||||
|
|
||||||
|
|
||||||
six:
|
six:
|
||||||
user: nora
|
user: nora
|
||||||
organization: nib
|
team: nib
|
||||||
role: 1
|
role: 1
|
||||||
assigned_by: nora
|
assigned_by: nora
|
||||||
|
|
||||||
|
|
||||||
eight:
|
eight:
|
||||||
user: nora
|
user: nora
|
||||||
organization: phylos
|
team: phylos
|
||||||
role: 2
|
role: 2
|
||||||
assigned_by: nora
|
assigned_by: nora
|
||||||
|
|
||||||
|
|
||||||
nine:
|
nine:
|
||||||
user: default
|
user: default
|
||||||
organization: biosistemika
|
team: biosistemika
|
||||||
role: 2
|
role: 2
|
||||||
assigned_by: default
|
assigned_by: default
|
||||||
|
|
||||||
|
|
||||||
ten:
|
ten:
|
||||||
user: default
|
user: default
|
||||||
organization: nib
|
team: nib
|
||||||
role: 2
|
role: 2
|
||||||
assigned_by: default
|
assigned_by: default
|
||||||
|
|
||||||
without_role:
|
without_role:
|
||||||
user: nora
|
user: nora
|
||||||
organization: nib
|
team: nib
|
||||||
role: -1
|
role: -1
|
||||||
assigned_by: steve
|
assigned_by: steve
|
||||||
|
|
||||||
without_user:
|
without_user:
|
||||||
user: 0
|
user: 0
|
||||||
organization: nib
|
team: nib
|
||||||
role: 1
|
role: 1
|
||||||
assigned_by: steve
|
assigned_by: steve
|
||||||
|
|
||||||
without_organization:
|
without_team:
|
||||||
user: nora
|
user: nora
|
||||||
organization: 0
|
team: 0
|
||||||
role: 1
|
role: 1
|
||||||
assigned_by: steve
|
assigned_by: steve
|
||||||
|
|
||||||
with_invalid_user:
|
with_invalid_user:
|
||||||
user_id: <%= Constants::INFINITY %>
|
user_id: <%= Constants::INFINITY %>
|
||||||
organization: nib
|
team: nib
|
||||||
role: 1
|
role: 1
|
||||||
assigned_by: steve
|
assigned_by: steve
|
||||||
|
|
||||||
with_invalid_organization:
|
with_invalid_team:
|
||||||
user: nora
|
user: nora
|
||||||
organization_id: <%= Constants::INFINITY %>
|
team_id: <%= Constants::INFINITY %>
|
||||||
role: 1
|
role: 1
|
||||||
assigned_by: steve
|
assigned_by: steve
|
|
@ -21,14 +21,14 @@ class AppMailerPreview < ActionMailer::Preview
|
||||||
Notification.new(
|
Notification.new(
|
||||||
type_of: :assignment,
|
type_of: :assignment,
|
||||||
title: I18n.t(
|
title: I18n.t(
|
||||||
'notifications.assign_user_to_organization',
|
'notifications.assign_user_to_team',
|
||||||
assigned_user: fake_user_2.full_name,
|
assigned_user: fake_user_2.full_name,
|
||||||
role: 'Administrator',
|
role: 'Administrator',
|
||||||
organization: fake_org.name,
|
team: fake_team.name,
|
||||||
assigned_by_user: fake_user.full_name
|
assigned_by_user: fake_user.full_name
|
||||||
),
|
),
|
||||||
message: ActionController::Base.helpers.sanitize(
|
message: ActionController::Base.helpers.sanitize(
|
||||||
"<a href='#' target='_blank'>#{fake_org.name}</a>"
|
"<a href='#' target='_blank'>#{fake_team.name}</a>"
|
||||||
),
|
),
|
||||||
generator_user: fake_user,
|
generator_user: fake_user,
|
||||||
created_at: Time.now
|
created_at: Time.now
|
||||||
|
@ -93,8 +93,8 @@ class AppMailerPreview < ActionMailer::Preview
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fake_org
|
def fake_team
|
||||||
Organization.new(
|
Team.new(
|
||||||
name: 'Greatest musicians of all time'
|
name: 'Greatest musicians of all time'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,21 +15,21 @@ class CustomFieldTest < ActiveSupport::TestCase
|
||||||
'Added on',
|
'Added on',
|
||||||
'Added by'])
|
'Added by'])
|
||||||
|
|
||||||
test "should validate with correct data" do
|
test 'should validate with correct data' do
|
||||||
assert @custom_field.valid?
|
assert @custom_field.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should not validate with non existent user" do
|
test 'should not validate with non existent user' do
|
||||||
@custom_field.user_id = 11231231
|
@custom_field.user_id = 11231231
|
||||||
assert_not @custom_field.valid?
|
assert_not @custom_field.valid?
|
||||||
@custom_field.user = nil
|
@custom_field.user = nil
|
||||||
assert_not @custom_field.valid?
|
assert_not @custom_field.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should not validate with non existent organization" do
|
test 'should not validate with non existent team' do
|
||||||
@custom_field.organization_id = 1231231
|
@custom_field.team_id = 1231231
|
||||||
assert_not @custom_field.valid?
|
assert_not @custom_field.valid?
|
||||||
@custom_field.organization = nil
|
@custom_field.team = nil
|
||||||
assert_not @custom_field.valid?
|
assert_not @custom_field.valid?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,28 +1,27 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class LogTest < ActiveSupport::TestCase
|
class LogTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@log = logs(:one)
|
@log = logs(:one)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should validate log with valid data" do
|
test 'should validate log with valid data' do
|
||||||
assert @log.valid?
|
assert @log.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should have non-blank message" do
|
test 'should have non-blank message' do
|
||||||
@log.message = ""
|
@log.message = ''
|
||||||
assert @log.invalid?, "Log with blank message returns valid? = true"
|
assert @log.invalid?, 'Log with blank message returns valid? = true'
|
||||||
@log.message = nil
|
@log.message = nil
|
||||||
assert @log.invalid?, "Log with nil message returns valid? = true"
|
assert @log.invalid?, 'Log with nil message returns valid? = true'
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should have organization" do
|
test 'should have team' do
|
||||||
@log.organization_id = 12321321
|
@log.team_id = 12321321
|
||||||
assert @log.invalid?, "Log without organization returns valid? = true"
|
assert @log.invalid?, 'Log without team returns valid? = true'
|
||||||
@log.organization = nil
|
@log.team = nil
|
||||||
assert @log.invalid?, "Log without organization returns valid? = true"
|
assert @log.invalid?, 'Log without team returns valid? = true'
|
||||||
@log.organization = Organization.new
|
@log.team = Team.new
|
||||||
assert @log.valid?, "Log with organization returns valid? = false"
|
assert @log.valid?, 'Log with team returns valid? = false'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
require 'test_helper'
|
|
||||||
|
|
||||||
class OrganizationTest < ActiveSupport::TestCase
|
|
||||||
def setup
|
|
||||||
@org = organizations(:test)
|
|
||||||
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 organization default values" do
|
|
||||||
assert @org.valid?
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should have non-blank name" do
|
|
||||||
@org.name = ""
|
|
||||||
assert @org.invalid?, "Organization with blank name returns valid? = true"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should have space_taken present" do
|
|
||||||
@org.space_taken = nil
|
|
||||||
assert @org.invalid?, "Organization without space_taken returns valid? = true"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "space_taken_defaults_to_value" do
|
|
||||||
org = Organization.new
|
|
||||||
assert_equal Constants::MINIMAL_ORGANIZATION_SPACE_TAKEN, org.space_taken
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should save log message" do
|
|
||||||
message = "This is test message"
|
|
||||||
@org.log(message)
|
|
||||||
log_message = Log.last.message[26..-1]
|
|
||||||
assert_equal log_message, message
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should open spreadsheet file" do
|
|
||||||
skip
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -16,58 +16,59 @@ class ProjectTest < ActiveSupport::TestCase
|
||||||
.is_at_least(Constants::NAME_MIN_LENGTH)
|
.is_at_least(Constants::NAME_MIN_LENGTH)
|
||||||
.is_at_most(Constants::NAME_MAX_LENGTH)
|
.is_at_most(Constants::NAME_MAX_LENGTH)
|
||||||
|
|
||||||
test "should have non-blank name" do
|
test 'should have non-blank name' do
|
||||||
@project.name = ""
|
@project.name = ''
|
||||||
assert @project.invalid?, "Project with blank name returns valid? = true"
|
assert @project.invalid?, 'Project with blank name returns valid? = true'
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should have organization-wide unique name" do
|
test 'should have team-wide unique name' do
|
||||||
@project.name = @project2.name
|
@project.name = @project2.name
|
||||||
assert @project.invalid?, "Project with non-unique organization-wide name returns valid? = true"
|
assert @project.invalid?,
|
||||||
|
'Project with non-unique team-wide name returns valid? = true'
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should not have non-organization-wide unique name" do
|
test 'should not have non-team-wide unique name' do
|
||||||
@project.name = @project3.name
|
@project.name = @project3.name
|
||||||
assert @project.valid?, "Project with non-unique name in different organizations returns valid? = false"
|
assert @project.valid?,
|
||||||
|
'Project with non-unique name in different teams ' \
|
||||||
|
'returns valid? = false'
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should have default visibility & archived" do
|
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(
|
project = Project.new(
|
||||||
name: "sample project",
|
name: 'test project',
|
||||||
organization_id: organizations(: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 organization" do
|
|
||||||
@project.organization = nil
|
|
||||||
assert_not @project.valid?, "Project without organization returns valid? = true"
|
|
||||||
@project.organization_id = 12321321
|
|
||||||
assert_not @project.valid?, "Project with organization returls valid? = false"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should have archived set" do
|
|
||||||
project = Project.new(
|
|
||||||
name: "test project",
|
|
||||||
visibility: 1,
|
visibility: 1,
|
||||||
organization_id: organizations(:biosistemika).id
|
team_id: teams(:biosistemika).id
|
||||||
)
|
)
|
||||||
assert_archived_present(project)
|
assert_archived_present(project)
|
||||||
assert_active_is_inverse_of_archived(project)
|
assert_active_is_inverse_of_archived(project)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "archiving should work" do
|
test 'archiving should work' do
|
||||||
user = users(:steve)
|
user = users(:steve)
|
||||||
project = Project.new(
|
project = Project.new(name: 'test project',
|
||||||
name: "test project",
|
|
||||||
visibility: 1,
|
visibility: 1,
|
||||||
organization_id: organizations(:biosistemika).id,
|
team_id: teams(:biosistemika).id)
|
||||||
)
|
|
||||||
project.save
|
project.save
|
||||||
archive_and_restore_action_test(project, user)
|
archive_and_restore_action_test(project, user)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "where_attributes_like should work" do
|
test 'where_attributes_like should work' do
|
||||||
attributes_like_test(Project, :name, "star")
|
attributes_like_test(Project, :name, 'star')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,20 +3,20 @@ require 'test_helper'
|
||||||
class ProtocolTest < ActiveSupport::TestCase
|
class ProtocolTest < ActiveSupport::TestCase
|
||||||
def setup
|
def setup
|
||||||
@user = users(:steve)
|
@user = users(:steve)
|
||||||
@org = organizations(:biosistemika)
|
@team = teams(:biosistemika)
|
||||||
@my_module = my_modules(:sample_prep)
|
@my_module = my_modules(:sample_prep)
|
||||||
@global = protocols(:rna_test_protocol_global)
|
@global = protocols(:rna_test_protocol_global)
|
||||||
|
|
||||||
@p = Protocol.new(
|
@p = Protocol.new(
|
||||||
my_module: @my_module,
|
my_module: @my_module,
|
||||||
organization: @org
|
team: @team
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
should validate_length_of(:name).is_at_most(Constants::NAME_MAX_LENGTH)
|
should validate_length_of(:name).is_at_most(Constants::NAME_MAX_LENGTH)
|
||||||
should validate_length_of(:description).is_at_most(Constants::TEXT_MAX_LENGTH)
|
should validate_length_of(:description).is_at_most(Constants::TEXT_MAX_LENGTH)
|
||||||
|
|
||||||
test "protocol_type enum works" do
|
test 'protocol_type enum works' do
|
||||||
@p.protocol_type = :unlinked
|
@p.protocol_type = :unlinked
|
||||||
assert @p.in_module?
|
assert @p.in_module?
|
||||||
@p.protocol_type = :linked
|
@p.protocol_type = :linked
|
||||||
|
@ -29,31 +29,31 @@ class ProtocolTest < ActiveSupport::TestCase
|
||||||
assert @p.in_repository?
|
assert @p.in_repository?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should not validate without organization" do
|
test 'should not validate without team' do
|
||||||
@p.organization = @org
|
@p.team = @team
|
||||||
assert @p.valid?
|
assert @p.valid?
|
||||||
@p.organization = nil
|
@p.team = nil
|
||||||
assert_not @p.valid?
|
assert_not @p.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should not validate without protocol type" do
|
test 'should not validate without protocol type' do
|
||||||
assert @p.valid?
|
assert @p.valid?
|
||||||
@p.protocol_type = nil
|
@p.protocol_type = nil
|
||||||
assert_not @p.valid?
|
assert_not @p.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should count steps of protocol" do
|
test 'should count steps of protocol' do
|
||||||
assert_equal 0, @p.number_of_steps
|
assert_equal 0, @p.number_of_steps
|
||||||
end
|
end
|
||||||
|
|
||||||
test "specific validations for :unlinked" do
|
test 'specific validations for :unlinked' do
|
||||||
p = new_unlinked_protocol
|
p = new_unlinked_protocol
|
||||||
assert p.valid?
|
assert p.valid?
|
||||||
p.my_module = nil
|
p.my_module = nil
|
||||||
assert_not p.valid?
|
assert_not p.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "specific validations for :linked" do
|
test 'specific validations for :linked' do
|
||||||
p = new_linked_protocol
|
p = new_linked_protocol
|
||||||
assert p.valid?
|
assert p.valid?
|
||||||
|
|
||||||
|
@ -73,17 +73,17 @@ class ProtocolTest < ActiveSupport::TestCase
|
||||||
assert_not p.valid?
|
assert_not p.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "specific validations for :in_repository" do
|
test 'specific validations for :in_repository' do
|
||||||
[
|
[
|
||||||
:in_repository_private,
|
:in_repository_private,
|
||||||
:in_repository_public,
|
:in_repository_public,
|
||||||
:in_repository_archived
|
:in_repository_archived
|
||||||
].each do |protocol_type|
|
].each do |protocol_type|
|
||||||
p = new_repository_protocol(protocol_type)
|
p = new_repository_protocol(protocol_type)
|
||||||
if protocol_type == :in_repository_archived then
|
if protocol_type == :in_repository_archived
|
||||||
p.archived_by = @user
|
p.archived_by = @user
|
||||||
p.archived_on = Time.now
|
p.archived_on = Time.now
|
||||||
elsif protocol_type == :in_repository_public then
|
elsif protocol_type == :in_repository_public
|
||||||
p.published_on = Time.now
|
p.published_on = Time.now
|
||||||
end
|
end
|
||||||
assert p.valid?
|
assert p.valid?
|
||||||
|
@ -109,7 +109,7 @@ class ProtocolTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "specific validations for :in_repository_public" do
|
test 'specific validations for :in_repository_public' do
|
||||||
p = new_repository_protocol(:in_repository_public)
|
p = new_repository_protocol(:in_repository_public)
|
||||||
p.published_on = nil
|
p.published_on = nil
|
||||||
assert_not p.valid?
|
assert_not p.valid?
|
||||||
|
@ -118,7 +118,7 @@ class ProtocolTest < ActiveSupport::TestCase
|
||||||
assert p.valid?
|
assert p.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "specific validations for :in_repository_archived" do
|
test 'specific validations for :in_repository_archived' do
|
||||||
p = new_repository_protocol(:in_repository_archived)
|
p = new_repository_protocol(:in_repository_archived)
|
||||||
p.archived_by = nil
|
p.archived_by = nil
|
||||||
p.archived_on = nil
|
p.archived_on = nil
|
||||||
|
@ -136,7 +136,7 @@ class ProtocolTest < ActiveSupport::TestCase
|
||||||
def new_unlinked_protocol
|
def new_unlinked_protocol
|
||||||
Protocol.new(
|
Protocol.new(
|
||||||
my_module: @my_module,
|
my_module: @my_module,
|
||||||
organization: @org
|
team: @team
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class ProtocolTest < ActiveSupport::TestCase
|
||||||
Protocol.new(
|
Protocol.new(
|
||||||
protocol_type: :linked,
|
protocol_type: :linked,
|
||||||
my_module: @my_module,
|
my_module: @my_module,
|
||||||
organization: @org,
|
team: @team,
|
||||||
added_by: @user,
|
added_by: @user,
|
||||||
parent: @global,
|
parent: @global,
|
||||||
parent_updated_at: @global.updated_at
|
parent_updated_at: @global.updated_at
|
||||||
|
@ -153,11 +153,10 @@ class ProtocolTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def new_repository_protocol(type)
|
def new_repository_protocol(type)
|
||||||
Protocol.new(
|
Protocol.new(
|
||||||
name: "Test protocol",
|
name: 'Test protocol',
|
||||||
protocol_type: type,
|
protocol_type: type,
|
||||||
organization: @org,
|
team: @team,
|
||||||
added_by: @user
|
added_by: @user
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,14 +9,14 @@ class SampleGroupTest < ActiveSupport::TestCase
|
||||||
should validate_length_of(:name).is_at_most(Constants::NAME_MAX_LENGTH)
|
should validate_length_of(:name).is_at_most(Constants::NAME_MAX_LENGTH)
|
||||||
should validate_presence_of(:color)
|
should validate_presence_of(:color)
|
||||||
should validate_length_of(:color).is_at_most(Constants::COLOR_MAX_LENGTH)
|
should validate_length_of(:color).is_at_most(Constants::COLOR_MAX_LENGTH)
|
||||||
should validate_presence_of(:organization)
|
should validate_presence_of(:team)
|
||||||
|
|
||||||
test "should validate with correct data" do
|
test 'should validate with correct data' do
|
||||||
assert @sample_group.valid?
|
assert @sample_group.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should not validate without organization" do
|
test 'should not validate without team' do
|
||||||
@sample_group.organization = nil
|
@sample_group.team = nil
|
||||||
assert_not @sample_group.valid?
|
assert_not @sample_group.valid?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,31 +5,30 @@ class SampleMyModuleTest < ActiveSupport::TestCase
|
||||||
@sample_module = sample_my_modules(:one)
|
@sample_module = sample_my_modules(:one)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should validate with correct data" do
|
test 'should validate with correct data' do
|
||||||
assert @sample_module.valid?
|
assert @sample_module.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should not validate with non existent sample" do
|
test 'should not validate with non existent sample' do
|
||||||
@sample_module.sample_id = 123123213
|
@sample_module.sample_id = 123123213
|
||||||
assert_not @sample_module.valid?
|
assert_not @sample_module.valid?
|
||||||
@sample_module.sample = nil
|
@sample_module.sample = nil
|
||||||
assert_not @sample_module.valid?
|
assert_not @sample_module.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should not validate with non existent my_module" do
|
test 'should not validate with non existent my_module' do
|
||||||
@sample_module.my_module_id = 12312312
|
@sample_module.my_module_id = 12312312
|
||||||
assert_not @sample_module.valid?
|
assert_not @sample_module.valid?
|
||||||
@sample_module.my_module = nil
|
@sample_module.my_module = nil
|
||||||
assert_not @sample_module.valid?
|
assert_not @sample_module.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should have association my_module <-> sample" do
|
test 'should have association my_module <-> sample' do
|
||||||
sample = Sample.create(
|
sample = Sample.create(name: 'test sample',
|
||||||
name: "test sample",
|
|
||||||
user: users(:jlaw),
|
user: users(:jlaw),
|
||||||
organization: organizations(:biosistemika))
|
team: teams(:biosistemika))
|
||||||
my_module = MyModule.create(
|
my_module = MyModule.create(
|
||||||
name: "test module",
|
name: 'test module',
|
||||||
experiment: experiments(:philadelphia),
|
experiment: experiments(:philadelphia),
|
||||||
my_module_group: my_module_groups(:wf1)
|
my_module_group: my_module_groups(:wf1)
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,47 +9,47 @@ class SampleTest < ActiveSupport::TestCase
|
||||||
@user = users(:jlaw)
|
@user = users(:jlaw)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should validate with correct data" do
|
test 'should validate with correct data' do
|
||||||
assert @sample.valid?
|
assert @sample.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should not validate without name" do
|
test 'should not validate without name' do
|
||||||
@sample.name = nil
|
@sample.name = nil
|
||||||
assert_not @sample.valid?
|
assert_not @sample.valid?
|
||||||
@sample.name = ""
|
@sample.name = ''
|
||||||
assert_not @sample.valid?
|
assert_not @sample.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should not validate with to long name" do
|
test 'should not validate with to long name' do
|
||||||
@sample.name *= 50
|
@sample.name *= 50
|
||||||
assert_not @sample.valid?
|
assert_not @sample.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should not validate with non existent user" do
|
test 'should not validate with non existent user' do
|
||||||
@sample.user_id = 1232132
|
@sample.user_id = 1232132
|
||||||
assert_not @sample.valid?
|
assert_not @sample.valid?
|
||||||
@sample.user = nil
|
@sample.user = nil
|
||||||
assert_not @sample.valid?
|
assert_not @sample.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should not validate with non existent organization" do
|
test 'should not validate with non existent team' do
|
||||||
@sample.organization_id = 1231232
|
@sample.team_id = 1231232
|
||||||
assert_not @sample.valid?
|
assert_not @sample.valid?
|
||||||
@sample.organization = nil
|
@sample.team = nil
|
||||||
assert_not @sample.valid?
|
assert_not @sample.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "where_attributes_like should work" do
|
test 'where_attributes_like should work' do
|
||||||
attributes_like_test(Sample, :name, "dna")
|
attributes_like_test(Sample, :name, 'dna')
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get user's samples" do
|
test 'should get user\'s samples' do
|
||||||
samples = Sample.search(@user, false)
|
samples = Sample.search(@user, false)
|
||||||
assert_equal 5, samples.size
|
assert_equal 5, samples.size
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should search user's samples by name" do
|
test 'should search user\'s samples by name' do
|
||||||
samples = Sample.search(@user, false, "test")
|
samples = Sample.search(@user, false, 'test')
|
||||||
assert_equal 2, samples.size
|
assert_equal 2, samples.size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,16 +7,16 @@ class SampleTypeTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
should validate_length_of(:name).is_at_most(Constants::NAME_MAX_LENGTH)
|
should validate_length_of(:name).is_at_most(Constants::NAME_MAX_LENGTH)
|
||||||
should validate_presence_of(:name)
|
should validate_presence_of(:name)
|
||||||
should validate_presence_of(:organization)
|
should validate_presence_of(:team)
|
||||||
|
|
||||||
test 'should validate with correct data' do
|
test 'should validate with correct data' do
|
||||||
assert @sample_type.valid?
|
assert @sample_type.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'should not validate without organization' do
|
test 'should not validate without team' do
|
||||||
@sample_type.organization_id = 12321321
|
@sample_type.team_id = 12321321
|
||||||
assert_not @sample_type.valid?
|
assert_not @sample_type.valid?
|
||||||
@sample_type.organization = nil
|
@sample_type.team = nil
|
||||||
assert_not @sample_type.valid?
|
assert_not @sample_type.valid?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
45
test/models/team_test.rb
Normal file
45
test/models/team_test.rb
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class TeamTest < ActiveSupport::TestCase
|
||||||
|
def setup
|
||||||
|
@team = teams(:test)
|
||||||
|
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 team default values' do
|
||||||
|
assert @team.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'should have non-blank name' do
|
||||||
|
@team.name = ''
|
||||||
|
assert @team.invalid?, 'Team with blank name returns valid? = true'
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'should have space_taken present' do
|
||||||
|
@team.space_taken = nil
|
||||||
|
assert @team.invalid?,
|
||||||
|
'Team without space_taken returns valid? = true'
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'space_taken_defaults_to_value' do
|
||||||
|
team = Team.new
|
||||||
|
assert_equal Constants::MINIMAL_TEAM_SPACE_TAKEN, team.space_taken
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'should save log message' do
|
||||||
|
message = 'This is test message'
|
||||||
|
@team.log(message)
|
||||||
|
log_message = Log.last.message[26..-1]
|
||||||
|
assert_equal log_message, message
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'should open spreadsheet file' do
|
||||||
|
skip
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,67 +0,0 @@
|
||||||
require 'test_helper'
|
|
||||||
|
|
||||||
class UserOrganizationTest < ActiveSupport::TestCase
|
|
||||||
def setup
|
|
||||||
@user_org = user_organizations(:one)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Test role attribute
|
|
||||||
test "should not save user organization without role" do
|
|
||||||
assert_not user_organizations(:without_role).save,
|
|
||||||
"Saved user organization without role"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should have default role" do
|
|
||||||
assert @user_org.normal_user?,
|
|
||||||
"User organization does not have default normal_user role"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should set valid role values" do
|
|
||||||
assert_nothing_raised(ArgumentError,
|
|
||||||
"User organization role was set with invalid role value") {
|
|
||||||
@user_org.role = 0
|
|
||||||
@user_org.role = 1
|
|
||||||
@user_org.role = 2
|
|
||||||
@user_org.role = "guest"
|
|
||||||
@user_org.role = "normal_user"
|
|
||||||
@user_org.role = "admin"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should not have undefined role" do
|
|
||||||
assert_raises(ArgumentError,
|
|
||||||
"User organization role can not be set to undefined numeric role value") {
|
|
||||||
@user_org.role = 5
|
|
||||||
}
|
|
||||||
assert_raises(ArgumentError,
|
|
||||||
"User organization role can not be set to undefined role value") {
|
|
||||||
@user_org.role = "gatekeeper"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
# Test user attribute
|
|
||||||
test "should not save user organization without user" do
|
|
||||||
assert_not user_organizations(:without_user).save,
|
|
||||||
"Saved user organization without user"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should not associate unexisting user" do
|
|
||||||
assert_raises(ActiveRecord::RecordInvalid,
|
|
||||||
"User organization saved unexisting user association") {
|
|
||||||
user_organizations(:with_invalid_user).save!
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
# Test organization attribute
|
|
||||||
test "should not save user organization without organization" do
|
|
||||||
assert_not user_organizations(:without_organization).save,
|
|
||||||
"Saved user organization without organization"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should not associate unexisting organization" do
|
|
||||||
assert_raises(ActiveRecord::RecordInvalid,
|
|
||||||
"User organization saved unexisting organization association") {
|
|
||||||
user_organizations(:with_invalid_organization).save!
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
69
test/models/user_team_test.rb
Normal file
69
test/models/user_team_test.rb
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class UserTeamTest < ActiveSupport::TestCase
|
||||||
|
def setup
|
||||||
|
@user_team = user_teams(:one)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Test role attribute
|
||||||
|
test 'should not save user team without role' do
|
||||||
|
assert_not user_teams(:without_role).save,
|
||||||
|
'Saved user team without role'
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'should have default role' do
|
||||||
|
assert @user_team.normal_user?,
|
||||||
|
'User team does not have default normal_user role'
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'should set valid role values' do
|
||||||
|
assert_nothing_raised(
|
||||||
|
ArgumentError,
|
||||||
|
'User team role was set with invalid role value'
|
||||||
|
) do
|
||||||
|
@user_team.role = 0
|
||||||
|
@user_team.role = 1
|
||||||
|
@user_team.role = 2
|
||||||
|
@user_team.role = 'guest'
|
||||||
|
@user_team.role = 'normal_user'
|
||||||
|
@user_team.role = 'admin'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'should not have undefined role' do
|
||||||
|
assert_raises(
|
||||||
|
ArgumentError,
|
||||||
|
'User team role can not be set to undefined numeric role value'
|
||||||
|
) { @user_team.role = 5 }
|
||||||
|
assert_raises(
|
||||||
|
ArgumentError,
|
||||||
|
'User team role can not be set to undefined role value'
|
||||||
|
) { @user_team.role = 'gatekeeper' }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Test user attribute
|
||||||
|
test 'should not save user team without user' do
|
||||||
|
assert_not user_teams(:without_user).save,
|
||||||
|
'Saved user team without user'
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'should not associate unexisting user' do
|
||||||
|
assert_raises(
|
||||||
|
ActiveRecord::RecordInvalid,
|
||||||
|
'User team saved unexisting user association'
|
||||||
|
) { user_teams(:with_invalid_user).save! }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Test team attribute
|
||||||
|
test 'should not save user team without team' do
|
||||||
|
assert_not user_teams(:without_team).save,
|
||||||
|
'Saved user team without team'
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'should not associate unexisting team' do
|
||||||
|
assert_raises(
|
||||||
|
ActiveRecord::RecordInvalid,
|
||||||
|
'User team saved unexisting team association'
|
||||||
|
) { user_teams(:with_invalid_team).save! }
|
||||||
|
end
|
||||||
|
end
|
|
@ -4,7 +4,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
def setup
|
def setup
|
||||||
@user = users(:john)
|
@user = users(:john)
|
||||||
@user2 = users(:steve)
|
@user2 = users(:steve)
|
||||||
@org = organizations(:biosistemika)
|
@team = teams(:biosistemika)
|
||||||
end
|
end
|
||||||
|
|
||||||
should validate_presence_of(:full_name)
|
should validate_presence_of(:full_name)
|
||||||
|
@ -14,107 +14,108 @@ class UserTest < ActiveSupport::TestCase
|
||||||
.is_at_most(Constants::USER_INITIALS_MAX_LENGTH)
|
.is_at_most(Constants::USER_INITIALS_MAX_LENGTH)
|
||||||
|
|
||||||
# Test password attribute
|
# Test password attribute
|
||||||
test "should have non-blank password" do
|
test 'should have non-blank password' do
|
||||||
@user.password = ""
|
@user.password = ''
|
||||||
assert @user.invalid?, "User with blank email is not valid"
|
assert @user.invalid?, 'User with blank email is not valid'
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should have password with at least 8 characters" do
|
test 'should have password with at least 8 characters' do
|
||||||
@user.password = "1234567"
|
@user.password = '1234567'
|
||||||
assert @user.invalid?, "User with too short password is not valid"
|
assert @user.invalid?, 'User with too short password is not valid'
|
||||||
@user.password = "12345678"
|
@user.password = '12345678'
|
||||||
assert_not @user.invalid?, "User with password longer than 7 characters is valid"
|
assert_not @user.invalid?,
|
||||||
|
'User with password longer than 7 characters is valid'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Test email attribute
|
# Test email attribute
|
||||||
test "should have non-blank email" do
|
test 'should have non-blank email' do
|
||||||
@user.email = ""
|
@user.email = ''
|
||||||
assert @user.invalid?, "User with blank email is not valid"
|
assert @user.invalid?, 'User with blank email is not valid'
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should have unique email" do
|
test 'should have unique email' do
|
||||||
@user.email = @user2.email
|
@user.email = @user2.email
|
||||||
assert @user.invalid?, "User with non-unique email in not valid"
|
assert @user.invalid?, 'User with non-unique email in not valid'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Test methods
|
# Test methods
|
||||||
test "should get projects for organization" do
|
test 'should get projects for team' do
|
||||||
org_projects = @user2.projects_by_orgs(@org.id)
|
team_projects = @user2.projects_by_teams(@team.id)
|
||||||
assert_equal 1, org_projects.size, "Projects are grouped into one organization"
|
assert_equal 1, team_projects.size, 'Projects are grouped into one team'
|
||||||
assert_equal 4, org_projects[@org].size, "Organization group has many projects"
|
assert_equal 4, team_projects[@team].size, 'Team group has many projects'
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get archived projects for organization" do
|
test 'should get archived projects for team' do
|
||||||
org_projects = @user2.projects_by_orgs(@org.id, nil, true)
|
team_projects = @user2.projects_by_teams(@team.id, nil, true)
|
||||||
assert_equal 1, org_projects.size, "Projects are grouped into one organization"
|
assert_equal 1, team_projects.size, 'Projects are grouped into one team'
|
||||||
assert_equal 2, org_projects[@org].size, "Organization group has many projects"
|
assert_equal 2, team_projects[@team].size, 'Team group has many projects'
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should sort projects by create timestamp ascending" do
|
test 'should sort projects by create timestamp ascending' do
|
||||||
org_projects = @user2.projects_by_orgs(@org.id, "old")
|
team_projects = @user2.projects_by_teams(@team.id, 'old')
|
||||||
first_project = projects(:interfaces)
|
first_project = projects(:interfaces)
|
||||||
last_project = projects(:z_project)
|
last_project = projects(:z_project)
|
||||||
assert_equal first_project, org_projects[@org].first
|
assert_equal first_project, team_projects[@team].first
|
||||||
assert_equal last_project, org_projects[@org].last
|
assert_equal last_project, team_projects[@team].last
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should sort projects by create timestamp descending" do
|
test 'should sort projects by create timestamp descending' do
|
||||||
org_projects = @user2.projects_by_orgs(@org.id)
|
team_projects = @user2.projects_by_teams(@team.id)
|
||||||
first_project = projects(:z_project)
|
first_project = projects(:z_project)
|
||||||
last_project = projects(:interfaces)
|
last_project = projects(:interfaces)
|
||||||
assert_equal first_project, org_projects[@org].first
|
assert_equal first_project, team_projects[@team].first
|
||||||
assert_equal last_project, org_projects[@org].last
|
assert_equal last_project, team_projects[@team].last
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should sort projects by project name ascending" do
|
test 'should sort projects by project name ascending' do
|
||||||
org_projects = @user2.projects_by_orgs(@org.id, "atoz")
|
team_projects = @user2.projects_by_teams(@team.id, 'atoz')
|
||||||
first_project = projects(:a_project)
|
first_project = projects(:a_project)
|
||||||
last_project = projects(:z_project)
|
last_project = projects(:z_project)
|
||||||
assert_equal first_project, org_projects[@org].first
|
assert_equal first_project, team_projects[@team].first
|
||||||
assert_equal last_project, org_projects[@org].last
|
assert_equal last_project, team_projects[@team].last
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should sort projects by project name descending" do
|
test 'should sort projects by project name descending' do
|
||||||
org_projects = @user2.projects_by_orgs(@org.id, "ztoa")
|
team_projects = @user2.projects_by_teams(@team.id, 'ztoa')
|
||||||
first_project = projects(:z_project)
|
first_project = projects(:z_project)
|
||||||
last_project = projects(:a_project)
|
last_project = projects(:a_project)
|
||||||
assert_equal first_project, org_projects[@org].first
|
assert_equal first_project, team_projects[@team].first
|
||||||
assert_equal last_project, org_projects[@org].last
|
assert_equal last_project, team_projects[@team].last
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should sort archived projects by create timestamp ascending" do
|
test 'should sort archived projects by create timestamp ascending' do
|
||||||
org_projects = @user2.projects_by_orgs(@org.id, "old", true)
|
team_projects = @user2.projects_by_teams(@team.id, 'old', true)
|
||||||
first_project = projects(:a_archived_project)
|
first_project = projects(:a_archived_project)
|
||||||
last_project = projects(:z_archived_project)
|
last_project = projects(:z_archived_project)
|
||||||
assert_equal first_project, org_projects[@org].first
|
assert_equal first_project, team_projects[@team].first
|
||||||
assert_equal last_project, org_projects[@org].last
|
assert_equal last_project, team_projects[@team].last
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should sort archived projects by create timestamp descending" do
|
test 'should sort archived projects by create timestamp descending' do
|
||||||
org_projects = @user2.projects_by_orgs(@org.id, nil, true)
|
team_projects = @user2.projects_by_teams(@team.id, nil, true)
|
||||||
first_project = projects(:z_archived_project)
|
first_project = projects(:z_archived_project)
|
||||||
last_project = projects(:a_archived_project)
|
last_project = projects(:a_archived_project)
|
||||||
assert_equal first_project, org_projects[@org].first
|
assert_equal first_project, team_projects[@team].first
|
||||||
assert_equal last_project, org_projects[@org].last
|
assert_equal last_project, team_projects[@team].last
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should sort archived projects by project name ascending" do
|
test 'should sort archived projects by project name ascending' do
|
||||||
org_projects = @user2.projects_by_orgs(@org.id, "atoz", true)
|
team_projects = @user2.projects_by_teams(@team.id, 'atoz', true)
|
||||||
first_project = projects(:a_archived_project)
|
first_project = projects(:a_archived_project)
|
||||||
last_project = projects(:z_archived_project)
|
last_project = projects(:z_archived_project)
|
||||||
assert_equal first_project, org_projects[@org].first
|
assert_equal first_project, team_projects[@team].first
|
||||||
assert_equal last_project, org_projects[@org].last
|
assert_equal last_project, team_projects[@team].last
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should sort archived projects by project name descending" do
|
test 'should sort archived projects by project name descending' do
|
||||||
org_projects = @user2.projects_by_orgs(@org.id, "ztoa", true)
|
team_projects = @user2.projects_by_teams(@team.id, 'ztoa', true)
|
||||||
first_project = projects(:z_archived_project)
|
first_project = projects(:z_archived_project)
|
||||||
last_project = projects(:a_archived_project)
|
last_project = projects(:a_archived_project)
|
||||||
assert_equal first_project, org_projects[@org].first
|
assert_equal first_project, team_projects[@team].first
|
||||||
assert_equal last_project, org_projects[@org].last
|
assert_equal last_project, team_projects[@team].last
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get last activities" do
|
test 'should get last activities' do
|
||||||
last_activities = @user2.last_activities(0)
|
last_activities = @user2.last_activities(0)
|
||||||
first_activity = activities(:twelve)
|
first_activity = activities(:twelve)
|
||||||
last_activity = activities(:three)
|
last_activity = activities(:three)
|
||||||
|
@ -123,7 +124,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
assert_equal last_activity, last_activities.last
|
assert_equal last_activity, last_activities.last
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get specified number of last activities" do
|
test 'should get specified number of last activities' do
|
||||||
last_activities = @user2.last_activities(0, 4)
|
last_activities = @user2.last_activities(0, 4)
|
||||||
first_activity = activities(:twelve)
|
first_activity = activities(:twelve)
|
||||||
last_activity = activities(:nine)
|
last_activity = activities(:nine)
|
||||||
|
@ -132,19 +133,19 @@ class UserTest < ActiveSupport::TestCase
|
||||||
assert_equal last_activity, last_activities.last
|
assert_equal last_activity, last_activities.last
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should allow to change time zone" do
|
test 'should allow to change time zone' do
|
||||||
assert @user.valid?
|
assert @user.valid?
|
||||||
@user.time_zone = "Ljubljana"
|
@user.time_zone = 'Ljubljana'
|
||||||
assert @user.valid?
|
assert @user.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should validate time zone value" do
|
test 'should validate time zone value' do
|
||||||
assert @user.valid?
|
assert @user.valid?
|
||||||
@user.time_zone = "Very Strange Place on Earth"
|
@user.time_zone = 'Very Strange Place on Earth'
|
||||||
assert_not @user.valid?
|
assert_not @user.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should check if time zone value is set" do
|
test 'should check if time zone value is set' do
|
||||||
assert @user.valid?
|
assert @user.valid?
|
||||||
@user.time_zone = nil
|
@user.time_zone = nil
|
||||||
assert_not @user.valid?
|
assert_not @user.valid?
|
||||||
|
|
Loading…
Add table
Reference in a new issue