<?xml version="1.0" encoding="UTF-8"?>
<ticket>
  <assigned-user-id type="integer">17223</assigned-user-id>
  <attachments-count type="integer">0</attachments-count>
  <closed type="boolean">true</closed>
  <created-at type="datetime">2009-02-17T13:22:26-05:00</created-at>
  <creator-id type="integer">47724</creator-id>
  <milestone-due-on type="datetime">2009-05-22T00:00:00-04:00</milestone-due-on>
  <milestone-id type="integer">39155</milestone-id>
  <number type="integer">164</number>
  <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
  <priority type="integer">1</priority>
  <project-id type="integer">5807</project-id>
  <raw-data type="binary" nil="true" encoding="base64"></raw-data>
  <state>resolved</state>
  <tag>case_insensitive should_validate_uniqueness_of</tag>
  <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
  <updated-at type="datetime">2010-01-17T05:17:04-05:00</updated-at>
  <user-id type="integer">53404</user-id>
  <user-name>Vladimir Rybas</user-name>
  <creator-name>papyromancer</creator-name>
  <assigned-user-name>Joe Ferris</assigned-user-name>
  <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
  <milestone-title>2.11</milestone-title>
  <original-body>model/episode.rb
@@@ruby
class Episode &lt; ActiveRecord::Base
  belongs_to :user
  belongs_to :program
  has_one :video
  
  validates_presence_of :title
  validates_presence_of :description
  validates_presence_of :user_id
  
  validates_uniqueness_of :title, :case_sensitive =&gt; false
end
@@@

test/unit/episode_test.rb
@@@ruby
require 'test_helper'

class EpisodeTest &lt; ActiveSupport::TestCase
    should_belong_to :user
    should_validate_uniqueness_of :title, :case_sensitive =&gt; false
end
@@@

results of rake:
@@@
  1) Failure:
test: Episode should require unique value for title. (EpisodeTest)
    []:
@@@

Am I missing something obvious?</original-body>
  <latest-body>model/episode.rb
@@@ruby
class Episode &lt; ActiveRecord::Base
  belongs_to :user
  belongs_to :program
  has_one :video
  
  validates_presence_of :title
  validates_presence_of :description
  validates_presence_of :user_id
  
  validates_uniqueness_of :title, :case_sensitive =&gt; false
end
@@@

test/unit/episode_test.rb
@@@ruby
require 'test_helper'

class EpisodeTest &lt; ActiveSupport::TestCase
    should_belong_to :user
    should_validate_uniqueness_of :title, :case_sensitive =&gt; false
end
@@@

results of rake:
@@@
  1) Failure:
test: Episode should require unique value for title. (EpisodeTest)
    []:
@@@

Am I missing something obvious?</latest-body>
  <original-body-html>&lt;div&gt;&lt;p&gt;model/episode.rb @@@ruby class Episode &amp;lt; ActiveRecord::Base
belongs_to :user belongs_to :program has_one :video&lt;/p&gt;
&lt;p&gt;validates_presence_of :title validates_presence_of :description
validates_presence_of :user_id&lt;/p&gt;
&lt;p&gt;validates_uniqueness_of :title, :case_sensitive =&amp;gt; false
end&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;

test/unit/episode_test.rb
@@@ruby
require 'test_helper'

class EpisodeTest &amp;lt; ActiveSupport::TestCase
    should_belong_to :user
    should_validate_uniqueness_of :title, :case_sensitive =&amp;gt; false
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;results of rake:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  1) Failure:
test: Episode should require unique value for title. (EpisodeTest)
    []:
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Am I missing something obvious?&lt;/p&gt;&lt;/div&gt;</original-body-html>
  <versions type="array">
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>model/episode.rb
@@@ ruby
class Episode &lt; ActiveRecord::Base
  belongs_to :user
  belongs_to :program
  has_one :video
  
  validates_presence_of :title
  validates_presence_of :description
  validates_presence_of :user_id
  
  validates_uniqueness_of :title, :case_sensitive =&gt; false
end
@@@

test/unit/episode_test.rb
@@@ ruby
require 'test_helper'

class EpisodeTest &lt; ActiveSupport::TestCase
    should_belong_to :user
    should_validate_uniqueness_of :title, :case_sensitive =&gt; false
end
@@@

results of rake:
@@@ sh
  1) Failure:
test: Episode should require unique value for title. (EpisodeTest)
    []:
@@@

Am I missing something obvious?</body>
      <body-html>&lt;div&gt;&lt;p&gt;model/episode.rb&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
class Episode &amp;lt; ActiveRecord::Base
  belongs_to :user
  belongs_to :program
  has_one :video
  
  validates_presence_of :title
  validates_presence_of :description
  validates_presence_of :user_id
  
  validates_uniqueness_of :title, :case_sensitive =&amp;gt; false
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;test/unit/episode_test.rb&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
require 'test_helper'

class EpisodeTest &amp;lt; ActiveSupport::TestCase
    should_belong_to :user
    should_validate_uniqueness_of :title, :case_sensitive =&amp;gt; false
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;results of rake:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;
  1) Failure:
test: Episode should require unique value for title. (EpisodeTest)
    []:
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Am I missing something obvious?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-17T13:22:28-05:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>new</state>
      <tag>should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-02-17T13:25:11-05:00</updated-at>
      <user-id type="integer">47724</user-id>
      <user-name>papyromancer</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title nil="true"></milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I'm seeing this too; occurs for my existing app. However, I can't reproduce on a fresh app. Haven't pinned it down to anything yet.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I'm seeing this too; occurs for my existing app. However, I
can't reproduce on a fresh app. Haven't pinned it down to anything
yet.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-19T18:00:01-05:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: should_validate_uniqueness_of
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>new</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-02-19T18:00:03-05:00</updated-at>
      <user-id type="integer">3685</user-id>
      <user-name>Jonathan Sutherland</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title nil="true"></milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I'm getting this even without specifying :case_sensitive.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I'm getting this even without specifying :case_sensitive.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-27T20:41:18-05:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>new</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-02-27T20:41:21-05:00</updated-at>
      <user-id type="integer">48740</user-id>
      <user-name>Raphomet</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title nil="true"></milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Hmm.  I fixed it by moving my should_validate_uniqueness_of macro into a context block with a setup that generates my model from a Factory.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Hmm. I fixed it by moving my should_validate_uniqueness_of macro
into a context block with a setup that generates my model from a
Factory.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-27T20:44:30-05:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>new</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-02-27T20:44:35-05:00</updated-at>
      <user-id type="integer">48740</user-id>
      <user-name>Raphomet</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title nil="true"></milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I'm seeing the same message as Jonathan when I'm running my tests for a similar 2 models that I am trying to test.

@@@ ruby
class FactorTest &lt; ActiveSupport::TestCase

  should_belong_to :project
  should_validate_presence_of :name
  should_validate_uniqueness_of :name, :case_sensitive =&gt; false, :scoped_to =&gt; :project_id
  
end
@@@

which is the test for:

@@@ ruby
class Factor &lt; ActiveRecord::Base
  
  belongs_to :project
  validates_presence_of :name
  validates_uniqueness_of :name, :case_sensitive =&gt; false, :scope =&gt; :project_id
  
end
@@@

@Raphomet - Which model are you generating from a Factory?  Are you generating the model the test is for or the model that contains the scope?</body>
      <body-html>&lt;div&gt;&lt;p&gt;I'm seeing the same message as Jonathan when I'm running my
tests for a similar 2 models that I am trying to test.&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
class FactorTest &amp;lt; ActiveSupport::TestCase

  should_belong_to :project
  should_validate_presence_of :name
  should_validate_uniqueness_of :name, :case_sensitive =&amp;gt; false, :scoped_to =&amp;gt; :project_id
  
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which is the test for:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
class Factor &amp;lt; ActiveRecord::Base
  
  belongs_to :project
  validates_presence_of :name
  validates_uniqueness_of :name, :case_sensitive =&amp;gt; false, :scope =&amp;gt; :project_id
  
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;@Raphomet - Which model are you generating from a Factory? Are
you generating the model the test is for or the model that contains
the scope?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-28T10:15:36-05:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>new</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-02-28T10:15:37-05:00</updated-at>
      <user-id type="integer">48799</user-id>
      <user-name>Matthew Lang</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title nil="true"></milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>@Matthew Lang

The model the Test is for:

@@@
class TagTest &lt; ActiveSupport::TestCase
  context &quot;A tag&quot; do
    setup do
      @tag = Factory(:tag)
    end

    should_validate_uniqueness_of :name, :case_sensitive =&gt; false
  end
end
@@@

I'm using Factory Girl.  I'm not sure if this is the intended behavior from the developers, but it cleared up the error for me right away.  Hope that helps!</body>
      <body-html>&lt;div&gt;&lt;p&gt;@Matthew Lang&lt;/p&gt;
&lt;p&gt;The model the Test is for:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
class TagTest &amp;lt; ActiveSupport::TestCase
  context &amp;quot;A tag&amp;quot; do
    setup do
      @tag = Factory(:tag)
    end

    should_validate_uniqueness_of :name, :case_sensitive =&amp;gt; false
  end
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I'm using Factory Girl. I'm not sure if this is the intended
behavior from the developers, but it cleared up the error for me
right away. Hope that helps!&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-28T15:38:45-05:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>new</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-02-28T15:38:50-05:00</updated-at>
      <user-id type="integer">48740</user-id>
      <user-name>Raphomet</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title nil="true"></milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Thanks for the Raphomet.

So a factory for the model instance needs to be created when your validating the uniqueness of something.

Makes sense, but which I thought of this earlier.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Thanks for the Raphomet.&lt;/p&gt;
&lt;p&gt;So a factory for the model instance needs to be created when
your validating the uniqueness of something.&lt;/p&gt;
&lt;p&gt;Makes sense, but which I thought of this earlier.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-03-03T08:25:01-05:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>new</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-03-03T08:25:05-05:00</updated-at>
      <user-id type="integer">48799</user-id>
      <user-name>Matthew Lang</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title nil="true"></milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">17223</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>This is the expected behavior for this macro, but it's supposed to print out an error message when no existing records can be found. I'll look into why this error disappeared.</body>
      <body-html>&lt;div&gt;&lt;p&gt;This is the expected behavior for this macro, but it's supposed
to print out an error message when no existing records can be
found. I'll look into why this error disappeared.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-03-03T10:25:47-05:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- 
:assigned_user: 
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>new</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-03-03T10:25:51-05:00</updated-at>
      <user-id type="integer">17223</user-id>
      <user-name>Joe Ferris</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name>Joe Ferris</assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title nil="true"></milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">17223</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I think the root cause of this issue is because should_validate_uniqueness_of is testing a 'nil' scenario.

For a model whose only validation is validates_uniqueness_of, I get:

@@@
1) Failure:
test: Page should require case sensitive unique value for title. (PageTest)
...
vendor/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/context.rb:253:in `test: Page should require case sensitive unique value for title. ']:
errors to include &quot;has already been taken&quot; when title is set to nil, got no errors
@@@

For validates_uniqueness_of, Rails doesn't add an error when the attr is nil (that's the job of validates_presence_of).

Haven't looked further as to why it's testing nil yet.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I think the root cause of this issue is because
should_validate_uniqueness_of is testing a 'nil' scenario.&lt;/p&gt;
&lt;p&gt;For a model whose only validation is validates_uniqueness_of, I
get:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
1) Failure:
test: Page should require case sensitive unique value for title. (PageTest)
...
vendor/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/context.rb:253:in `test: Page should require case sensitive unique value for title. ']:
errors to include &amp;quot;has already been taken&amp;quot; when title is set to nil, got no errors
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For validates_uniqueness_of, Rails doesn't add an error when the
attr is nil (that's the job of validates_presence_of).&lt;/p&gt;
&lt;p&gt;Haven't looked further as to why it's testing nil yet.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-03-22T09:23:56-04:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>new</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-03-22T09:24:01-04:00</updated-at>
      <user-id type="integer">3685</user-id>
      <user-name>Jonathan Sutherland</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name>Joe Ferris</assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title nil="true"></milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">17223</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Inside validate_uniqueness_of_matcher.rb there's the following doc:

&lt;code&gt;
      # Internally, this uses values from existing records to test validations,
      # so this will always fail if you have not saved at least one record for
      # the model being tested, like so:
&lt;/code&gt;

... which sums it up nicely :P

This issue stung me also. I think a &quot;there was no records to clone&quot; error at test time would be good, as well as the above doc added to the should_validate_uniqueness_of doc... ?</body>
      <body-html>&lt;div&gt;&lt;p&gt;Inside validate_uniqueness_of_matcher.rb there's the following
doc:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;  # Internally, this uses values from existing records to test validations,
  # so this will always fail if you have not saved at least one record for
  # the model being tested, like so:
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;... which sums it up nicely :P&lt;/p&gt;
&lt;p&gt;This issue stung me also. I think a &quot;there was no records to
clone&quot; error at test time would be good, as well as the above doc
added to the should_validate_uniqueness_of doc... ?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-04-04T20:29:48-04:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>new</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-04-04T20:29:53-04:00</updated-at>
      <user-id type="integer">40291</user-id>
      <user-name>Alex Pooley</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name>Joe Ferris</assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title nil="true"></milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">17223</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body></body>
      <body-html></body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-05-05T15:48:24-04:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- 
:milestone: 
</diffable-attributes>
      <milestone-id type="integer">39155</milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>new</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-05-05T15:48:27-04:00</updated-at>
      <user-id type="integer">17223</user-id>
      <user-name>Joe Ferris</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name>Joe Ferris</assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title>2.11</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body></body>
      <body-html></body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-05-05T19:37:12-04:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- 
:assigned_user: 17223
</diffable-attributes>
      <milestone-id type="integer">39155</milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>new</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-05-05T19:37:15-04:00</updated-at>
      <user-id type="integer">17223</user-id>
      <user-name>Joe Ferris</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title>2.11</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">17223</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body></body>
      <body-html></body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-06-09T20:45:05-04:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- 
:assigned_user: 
</diffable-attributes>
      <milestone-id type="integer">39155</milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>new</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-06-09T20:45:05-04:00</updated-at>
      <user-id type="integer">17223</user-id>
      <user-name>Joe Ferris</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name>Joe Ferris</assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title>2.11</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">17223</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I believe this was fixed by this commit: http://github.com/thoughtbot/shoulda/commit/1ce9339d9c452d39c60eb2fd04156104e6e133e4

Please open a ticket over at Github issues if this problem persists after the next release of Shoulda: http://github.com/thoughtbot/shoulda/issues

Thanks,

-Joe</body>
      <body-html>&lt;div&gt;&lt;p&gt;I believe this was fixed by this commit: &lt;a href=
&quot;http://github.com/thoughtbot/shoulda/commit/1ce9339d9c452d39c60eb2fd04156104e6e133e4&quot;&gt;
http://github.com/thoughtbot/shoulda/commit/1ce9339d9c452d39c60eb2f...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Please open a ticket over at Github issues if this problem
persists after the next release of Shoulda: &lt;a href=
&quot;http://github.com/thoughtbot/shoulda/issues&quot;&gt;http://github.com/thoughtbot/shoulda/issues&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;-Joe&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-06-09T20:56:09-04:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- 
:state: new
</diffable-attributes>
      <milestone-id type="integer">39155</milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>resolved</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2009-06-09T20:56:09-04:00</updated-at>
      <user-id type="integer">17223</user-id>
      <user-name>Joe Ferris</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name>Joe Ferris</assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title>2.11</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">17223</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Could be done like that, while using Rspec and Factory Girl
@@@ ruby
lambda {Factory(:user); should_validate_uniqueness_of(:email); User.delete_all}.call
@@@</body>
      <body-html>&lt;div&gt;&lt;p&gt;Could be done like that, while using Rspec and Factory
Girl&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code class=
&quot;ruby&quot;&gt;lambda {Factory(:user); should_validate_uniqueness_of(:email); User.delete_all}.call&lt;/code&gt;
&lt;/pre&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2010-01-17T05:17:02-05:00</created-at>
      <creator-id type="integer">47724</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">39155</milestone-id>
      <number type="integer">164</number>
      <permalink>should_validate_uniqueness_of-model-case_sensitive-false-doesnt-validate-at-least-for-me</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">5807</project-id>
      <state>resolved</state>
      <tag>case_insensitive should_validate_uniqueness_of</tag>
      <title>should_validate_uniqueness_of, :model, :case_sensitive =&gt; false doesn't validate (at least for me) </title>
      <updated-at type="datetime">2010-01-17T05:17:04-05:00</updated-at>
      <user-id type="integer">53404</user-id>
      <user-name>Vladimir Rybas</user-name>
      <creator-name>papyromancer</creator-name>
      <assigned-user-name>Joe Ferris</assigned-user-name>
      <url>http://thoughtbot.lighthouseapp.com/projects/5807/tickets/164</url>
      <milestone-title>2.11</milestone-title>
    </version>
  </versions>
</ticket>
