Project initialize
This commit is contained in:
0
test/models/.keep
Normal file
0
test/models/.keep
Normal file
7
test/models/department_test.rb
Normal file
7
test/models/department_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class DepartmentTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
test/models/task_activity_test.rb
Normal file
7
test/models/task_activity_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TaskActivityTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
41
test/models/task_test.rb
Normal file
41
test/models/task_test.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TaskTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@user = users(:admin)
|
||||
end
|
||||
|
||||
test "should be valid with a title and creator" do
|
||||
task = Task.new(title: "Do something", creator: @user)
|
||||
assert task.valid?
|
||||
end
|
||||
|
||||
test "should be invalid without a title" do
|
||||
task = Task.new(title: "", creator: @user)
|
||||
assert_not task.valid?
|
||||
assert_includes task.errors[:title], "can't be blank"
|
||||
end
|
||||
|
||||
test "should be invalid without a creator" do
|
||||
task = Task.new(title: "Do something")
|
||||
assert_not task.valid?
|
||||
assert_includes task.errors[:creator], "can't be blank"
|
||||
end
|
||||
|
||||
test "incomplete scope returns only incomplete tasks" do
|
||||
Task.create!(title: "Incomplete", status: :open, creator: @user)
|
||||
Task.create!(title: "Complete", status: :completed, creator: @user)
|
||||
|
||||
# fixture 'one' has status: open
|
||||
assert_includes Task.incomplete, tasks(:one)
|
||||
assert_not_includes Task.incomplete, Task.find_by(status: :completed, title: "Complete")
|
||||
end
|
||||
|
||||
test "complete scope returns only completed tasks" do
|
||||
Task.create!(title: "Incomplete", status: :open, creator: @user)
|
||||
Task.create!(title: "Complete", status: :completed, creator: @user)
|
||||
|
||||
assert_includes Task.complete, Task.find_by(status: :completed, title: "Complete")
|
||||
assert_not_includes Task.complete, tasks(:one)
|
||||
end
|
||||
end
|
||||
7
test/models/user_test.rb
Normal file
7
test/models/user_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class UserTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user