|
|
|
|
2
|
|
2
|
|
3
|
class ActivityTest < ActiveSupport::TestCase
|
3
|
class ActivityTest < ActiveSupport::TestCase
|
4
|
test "activity's author should exist" do
|
4
|
test "activity's author should exist" do
|
5
|
- user = User.new(email: "test@test.com", username: "UserTest", password_digest: 'password')
|
|
|
|
|
5
|
+ user = User.new(email: "test@test.com", username: "UserTest", password_digest: '$6$12$password')
|
6
|
activity = Activity.new(name: "Pyheatpump", description: "A software to control heat pumps", author: user)
|
6
|
activity = Activity.new(name: "Pyheatpump", description: "A software to control heat pumps", author: user)
|
7
|
assert activity.valid?
|
7
|
assert activity.valid?
|
8
|
end
|
8
|
end
|
9
|
|
9
|
|
|
|
10
|
+ test "not valid if name does not exist" do
|
|
|
11
|
+ user = User.new(email: "test@test.com", username: "UserTest", password_digest: '$6$12$password')
|
|
|
12
|
+ activity = Activity.new(description: "A software to control heat pumps", author: user)
|
|
|
13
|
+ assert_not activity.valid?
|
|
|
14
|
+ end
|
|
|
15
|
+
|
10
|
test "not valid if author does not exist" do
|
16
|
test "not valid if author does not exist" do
|
11
|
activity = Activity.new(name: "Pyheatpump", description: "A software to control heat pumps", author: User.find_by_id(666))
|
17
|
activity = Activity.new(name: "Pyheatpump", description: "A software to control heat pumps", author: User.find_by_id(666))
|
12
|
assert_not activity.valid?
|
18
|
assert_not activity.valid?
|