forked from concerto/concerto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanuing feed unit tests & fixtures [concerto#94]
- Loading branch information
Showing
2 changed files
with
21 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
|
||
one: | ||
name: MyString | ||
description: MyText | ||
service: | ||
name: Service Events | ||
description: This feed is for community service related announcments | ||
parent_id: | ||
group: wtg | ||
|
||
two: | ||
name: MyString1 | ||
description: MyText | ||
announcements: | ||
name: Announcements | ||
description: Important Organizational Announcements | ||
parent_id: | ||
group: wtg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,22 @@ | ||
require 'test_helper' | ||
|
||
class FeedTest < ActiveSupport::TestCase | ||
#Test the fields that should be required | ||
test "name cannot be blank" do | ||
f = feeds(:one) | ||
feed = Feed.new(f.attributes) | ||
feed.name = "" | ||
assert !feed.valid?, "Feed name is blank" | ||
feed.name = "Blah" | ||
assert feed.valid?, "Feed name has entry" | ||
end | ||
test "group cannot be blank or unassociated" do | ||
f = feeds(:one) | ||
feed = Feed.new(f.attributes) | ||
feed.name = "ASDF" + feed.name #Make the name unique | ||
feed.group_id = "" | ||
assert !feed.valid?, "Feed group is blank" | ||
feed.group_id = 0 | ||
assert !feed.valid?, "Feed group is unassociated" | ||
feed.group_id = groups(:wtg).id | ||
assert feed.valid?, "Feed group is associated with wtg group" | ||
end | ||
#Test for duplicate names | ||
test "name cannot be duplicated" do | ||
f = feeds(:one) | ||
feed = Feed.new({:name => f.name, :group_id => groups(:rpitv).id}) | ||
assert_equal f.name, feed.name, "Names are set equal" | ||
assert !feed.valid?, "Names can't be equal" | ||
feed.name = "Fooasdasdasda" | ||
assert feed.valid?, "Unique name is OK" | ||
end | ||
|
||
#Test the content relationship | ||
# This test serves more to verify the setup of the | ||
# testing enviroment than the actual application | ||
test "has content" do | ||
f = feeds(:one) | ||
assert_equal f.contents.length, 2, "Feed only has 2 contents" | ||
assert f.contents.include?(contents(:one)), "Content one is included" | ||
assert f.contents.include?(contents(:old)), "Content old is included" | ||
# Attributes cannot be left empty/blank | ||
test "feed attributes must not be empty" do | ||
feed = Feed.new | ||
assert feed.invalid? | ||
assert feed.errors[:name].any? | ||
assert feed.errors[:group].any? | ||
end | ||
|
||
#Test the approved/pending/denied content relationship | ||
test "approved content" do | ||
f = feeds(:one) | ||
assert_equal f.approved_contents, [contents(:one)], "Approved content is approved" | ||
|
||
no_approved = feeds(:two) | ||
assert no_approved.approved_contents.empty?, "Denied content is not approved" | ||
# The feed name must be unique | ||
test "feed is now valid without a unique name" do | ||
feed = Feed.new(:name => feeds(:service).name, | ||
:description => "Another feed.", | ||
:group => groups(:rpitv)) | ||
|
||
assert feed.invalid? | ||
assert feed.errors[:name].any? | ||
end | ||
test "pending content" do | ||
f = feeds(:one) | ||
assert_equal f.pending_contents, [contents(:old)], "Pending content is pending" | ||
|
||
no_pending = feeds(:two) | ||
assert no_pending.pending_contents.empty?, "Denied content is not pending" | ||
end | ||
test "denied content" do | ||
f = feeds(:two) | ||
assert_equal f.denied_contents, [contents(:one)], "Denied content is denied" | ||
|
||
no_denied = feeds(:one) | ||
assert no_denied.denied_contents.empty?, "Pending|Approved is not denied" | ||
end | ||
|
||
|
||
end |