2013-04-02 02:43:01 -04:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class AlertTest < ActiveSupport::TestCase
|
2013-05-31 00:27:38 -04:00
|
|
|
def setup
|
|
|
|
@alert_one = alerts(:one)
|
|
|
|
@alert_two = alerts(:two)
|
|
|
|
@alert_three = alerts(:three)
|
|
|
|
|
|
|
|
@user_one = users(:one)
|
|
|
|
end
|
|
|
|
|
2013-05-31 22:53:35 -04:00
|
|
|
test "should create a new alert" do
|
2013-05-31 00:27:38 -04:00
|
|
|
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
|
|
|
|
|
2013-05-31 22:53:35 -04:00
|
|
|
test "should only return alerts for correct user when asked" do
|
|
|
|
assert Alert.user_alerts(@user_one).all? { |a| a.user_id == @user_one.id }
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should return the full course name" do
|
|
|
|
assert_equal @alert_one.course_name, "CSE 101"
|
|
|
|
end
|
2013-04-02 02:43:01 -04:00
|
|
|
end
|