Initial attempt at tests
This commit is contained in:
parent
d1ebae58b1
commit
11d1d1bf97
4 changed files with 48 additions and 17 deletions
|
@ -30,7 +30,7 @@ class Alert < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
|
|
||||||
def alerted?
|
def alerted?
|
||||||
@alerted
|
self.alerted
|
||||||
end
|
end
|
||||||
|
|
||||||
def course_name
|
def course_name
|
||||||
|
|
18
test/fixtures/alerts.yml
vendored
18
test/fixtures/alerts.yml
vendored
|
@ -2,12 +2,22 @@
|
||||||
|
|
||||||
one:
|
one:
|
||||||
user_id: 1
|
user_id: 1
|
||||||
department: MyString
|
department: CSE
|
||||||
course: MyString
|
course: 101
|
||||||
alerted: false
|
alerted: false
|
||||||
|
semester: US13
|
||||||
|
|
||||||
two:
|
two:
|
||||||
user_id: 1
|
user_id: 1
|
||||||
department: MyString
|
department: IAH
|
||||||
course: MyString
|
course: 241A
|
||||||
|
alerted: true
|
||||||
|
semester: FS13
|
||||||
|
|
||||||
|
three:
|
||||||
|
user_id: 2
|
||||||
|
department: TES
|
||||||
|
course: 312
|
||||||
alerted: false
|
alerted: false
|
||||||
|
semester: SS14
|
||||||
|
|
||||||
|
|
14
test/fixtures/users.yml
vendored
14
test/fixtures/users.yml
vendored
|
@ -1,11 +1,7 @@
|
||||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||||
|
one:
|
||||||
|
id: 1
|
||||||
|
|
||||||
|
two:
|
||||||
|
id: 2
|
||||||
|
|
||||||
# This model initially had no columns defined. If you add columns to the
|
|
||||||
# model remove the '{}' from the fixture names and add the columns immediately
|
|
||||||
# below each fixture, per the syntax in the comments below
|
|
||||||
#
|
|
||||||
one: {}
|
|
||||||
# column: value
|
|
||||||
#
|
|
||||||
two: {}
|
|
||||||
# column: value
|
|
||||||
|
|
|
@ -1,7 +1,32 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class AlertTest < ActiveSupport::TestCase
|
class AlertTest < ActiveSupport::TestCase
|
||||||
# test "the truth" do
|
def setup
|
||||||
# assert true
|
@alert_one = alerts(:one)
|
||||||
# end
|
@alert_two = alerts(:two)
|
||||||
|
@alert_three = alerts(:three)
|
||||||
|
|
||||||
|
@user_one = users(:one)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "creating a new alert creates an alert" do
|
||||||
|
assert_kind_of Alert, Alert.new
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should return false if has not been alerted" do
|
||||||
|
assert !@alert_one.alerted?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should return true if has been alerted" do
|
||||||
|
assert @alert_two.alerted?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should return alerts for user when asked" do
|
||||||
|
assert !Alert.user_alerts(@user_one).empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
#test "should only return alerts for correct user when asked" do
|
||||||
|
# again, should test with actual user
|
||||||
|
#assert Alert.user_alerts(@user_one).all? { |a| a == @user_one }
|
||||||
|
#end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue