Permalink
Browse files

removed tag test and added a shoulda validation to assert the associa…

…tion.
  • Loading branch information...
lunks committed Nov 27, 2010
1 parent 3e6c00d commit 8d9f20258cd317550d5a98bc61145eb86a29342f
Showing with 15 additions and 20 deletions.
  1. +15 −20 test/unit/organization_test.rb
@@ -3,47 +3,41 @@
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
class OrganizationTest < ActiveSupport::TestCase
-
- should validate_presence_of :name
+
+ should have_and_belong_to_many :tags
+
+ should validate_presence_of :name
should validate_presence_of :contact
should validate_presence_of :city
should validate_presence_of :country
should validate_presence_of :password
should validate_presence_of :email
- should validate_presence_of :announcer
+ should validate_presence_of :announcer
should validate_uniqueness_of :name
-
+
should_not allow_value("invalidmail").for(:email)
should_not allow_value("@b.com").for(:email)
should allow_value("a@b.com").for(:email)
should allow_value("valid.string+alias@mail.com").for(:email)
-
- should "return if the given tag is associated to the organization" do
- org = organizations(:wwf)
-
- assert org.has_tag?(tags(:cloth)), 'have tag cloth'
- assert org.has_tag?(tags(:food)), 'have tag food'
- assert !org.has_tag?(tags(:money)), 'doesn\'t has tag money'
- end
-
+
should "slug organization name" do
assert_equal 'nacao-da-vo-lurdes', Organization.slug_name('Nação da Vó Lurdes')
assert_equal 'santa-casa-de-misericordia-de-sao-paulo', Organization.slug_name('Santa Casa de Misericórdia de São Paulo')
end
-
+
should "slug city name" do
assert_equal 'jaragua do sul', Organization.slug_city('Jaraguá do Sul')
assert_equal 'sao paulo', Organization.slug_city('São Paulo')
end
-
+
should "create slug city automatically" do
org = organizations(:wwf)
-
+
org.city = 'Jaraguá do Sul'
assert_equal 'jaragua do sul', org.city_slug
assert org.save
-
+
org.city = 'São Paulo'
assert_equal 'sao paulo', org.city_slug
assert org.save
@@ -55,11 +49,11 @@ class OrganizationTest < ActiveSupport::TestCase
org = Organization.create(params)
assert_equal "minha-organizacao", org.name_slug, "name slug is '#{org.name_slug}', but 'minha-organizacao' was expected"
end
-
+
should "retrieve at most the parameter informed of organizations" do
orgs = Organization.get_random_list(2)
assert_operator orgs.count, :<=, 2
-
+
orgs = Organization.get_random_list(3)
assert_operator orgs.count, :<=, 3
@@ -69,5 +63,6 @@ class OrganizationTest < ActiveSupport::TestCase
orgs = Organization.get_random_list(6)
assert_operator orgs.count, :<=, 6
end
-
+
end
+

0 comments on commit 8d9f202

Please sign in to comment.