Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Failing test for ticket #33 - mixing translated and untranslated attr…

…ibutes
  • Loading branch information...
commit 22c2d748331f2f0b79cc9d979991452059c20380 1 parent 92217da
Robert Pankowecki (Gavdi) authored

Showing 1 changed file with 39 additions and 3 deletions. Show diff stats Hide diff stats

  1. +39 3 test/globalize3/dynamic_finders_test.rb
42 test/globalize3/dynamic_finders_test.rb
@@ -4,10 +4,8 @@
4 4
5 5 class DynamicFindersTest < Test::Unit::TestCase
6 6
7   - Rpa = "rpa@gavdi.com"
8   -
9 7 test "Does not break normal finders" do
10   - user = User.create!(:name => "name", :email => Rpa)
  8 + user = User.create!(:name => "name", :email => "email@example.org")
11 9
12 10 assert_equal user, User.find_by_email(user.email)
13 11 assert_equal [user], User.find_all_by_email([user.email])
@@ -120,4 +118,42 @@ def setup
120 118 assert_equal [], Post.find_all_by_content_and_title(@content, ["not existing"])
121 119 end
122 120
  121 +end
  122 +
  123 +class TranslatedAndNormalAttributeDynamicFindersTest < Test::Unit::TestCase
  124 +
  125 + def setup
  126 + @name1, @name2, @email = "n1", "n2", "email@example.org"
  127 + @p1 = User.create!(:name => @name1, :email => @email)
  128 + @p2 = User.create!(:name => @name2, :email => @email)
  129 + end
  130 +
  131 + test "find one element by two translation columns" do
  132 + assert_equal @p1, User.find_by_name_and_email(@name1, @email)
  133 + assert_equal @p2, User.find_by_email_and_name(@email, @name2)
  134 + end
  135 +
  136 + test "return nil for none existing values" do
  137 + assert_nil User.find_by_email_and_name(@email, "not exisiting")
  138 + assert_nil User.find_by_email_and_name("not existing", @name2)
  139 +
  140 + assert_nil User.find_by_name_and_email("not exisiting", @email)
  141 + assert_nil User.find_by_name_and_email(@name2, "not existing")
  142 + end
  143 +
  144 + test "find elements by two translation columns" do
  145 + two_results = User.find_all_by_name_and_email([@name1, @name2], @email)
  146 + assert two_results.include?(@p1)
  147 + assert two_results.include?(@p2)
  148 + assert_equal @p2, User.find_all_by_email_and_name(@email, @name2)
  149 + end
  150 +
  151 + test "returns empty result set for none existing values" do
  152 + assert_equal [], User.find_all_by_name_and_email([@name1, @name2], "not existing")
  153 + assert_equal [], User.find_all_by_name_and_email("not existing", @email)
  154 +
  155 + assert_equal [], User.find_all_by_email_and_name(["not existing"], @name1)
  156 + assert_equal [], User.find_all_by_email_and_name(@email, ["not existing"])
  157 + end
  158 +
123 159 end

0 comments on commit 22c2d74

Please sign in to comment.
Something went wrong with that request. Please try again.