Created
May 13, 2010 12:52
-
-
Save joeljunstrom/399792 to your computer and use it in GitHub Desktop.
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
require File.dirname(__FILE__) + '/../test_helper' | |
class MashAppTest < ActiveSupport::TestCase | |
context "A MashApp instance" do | |
setup do | |
@mash_app = Factory.create(:mash_app) | |
end | |
subject { @mash_app } | |
should_validate_presence_of :name, | |
:user_id, | |
:description | |
should_not_allow_mass_assignment_of :user_id, | |
:likes_count | |
should_belong_to :user | |
should_have_many :apps, :through => :mashed_apps | |
should_have_many :likes | |
should_have_many :tag_taggings | |
should_have_many :tags, :through => :tag_taggings | |
should "be taggable" do | |
assert @mash_app.respond_to?(:tag_list=) | |
end | |
should 'use spaces as tag delimiter' do | |
@mash_app.tag_list = 'one two three' | |
assert_equal ['one', 'two', 'three'], @mash_app.tag_list | |
end | |
should "use it's id and a parameterized name as param" do | |
@mash_app = Factory(:mash_app, :name => 'My mash app') | |
assert_equal "#{@mash_app.id}-my-mash-app", @mash_app.to_param | |
end | |
end | |
context "MashApps" do | |
setup do | |
@mash_apps = [] | |
10.times do |i| | |
@mash_apps << Factory(:mash_app, :likes_count => 10*i) | |
end | |
end | |
should "be ranked and accessible by likes over time" do | |
assert_equal 9, MashApp.popular.size, "Popular needs to have likes" | |
assert_equal 90, MashApp.popular.first.likes.size | |
assert_equal 10, MashApp.popular.last.likes.size | |
end | |
should "be ranked and accessible by new and popular" do | |
assert_equal @mash_apps.last, MashApp.recent.first | |
assert_equal @mash_apps.first, MashApp.recent.last | |
end | |
should "be searchable" do | |
assert false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment