[typo] Testing typo...

Matt Rose mattrose at folkwolf.net
Thu Jun 22 07:37:30 EDT 2006


It may get set by the database itself, I know on some versions of sql  
you can have a table with a column with a default value set.  I'll  
look into this a little bit later today.

As a complete aside, this is a great way to learn how Rails works.   
Thanks for all the help with this, guys.

Matt

On 21-Jun-06, at 11:48 PM, Scott Laird wrote:

> Hmm.  Hey, Piers, isn't the blog supposed to be set by default?  Where
> does that come from?
>
>
> Scott
>
> On 6/21/06, Matt Rose <mattrose at folkwolf.net> wrote:
>>
>> replying to myself here:  I managed to fix article_test.rb so that it
>> now passes all tests on sqlite
>> Should I submit patches for the files I fix?  I still haven't worked
>> out all the errors on postgres.  I'll work on that more, but I like
>> sqlite more, so I'll be concentrating on that platform.
>>
>>
>>
>> Before:
>>
>> mattrose at venice:~/typotest/typo.sqlite/test/unit$ ruby
>> article_test.rb.orig
>> Loaded suite article_test.rb.orig
>> Started
>> F...E.EEFEF......F.E.
>> Finished in 3.506417 seconds.
>>
>>    1) Failure:
>> test_create(ArticleTest) [article_test.rb.orig:24]:
>> <false> is not true.
>>
>>    2) Error:
>> test_find_published_by_category(ArticleTest):
>> ActiveRecord::RecordInvalid: Validation failed: Blog can't be blank
>>      /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/
>> activerecord/lib/active_record/validations.rb:736:in `save!'
>>      /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/
>> activerecord/lib/active_record/validations.rb:699:in `create!'
>>      article_test.rb.orig:178:in `test_find_published_by_category'
>>
>>    3) Error:
>> test_future_publishing(ArticleTest):
>> ActiveRecord::RecordInvalid: Validation failed: Blog can't be blank
>>      /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/
>> activerecord/lib/active_record/validations.rb:736:in `save!'
>>      /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/
>> activerecord/lib/active_record/validations.rb:699:in `create!'
>>      article_test.rb.orig:150:in `test_future_publishing'
>>
>>    4) Error:
>> test_future_publishing_without_published_flag(ArticleTest):
>> ActiveRecord::RecordInvalid: Validation failed: Blog can't be blank
>>      /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/
>> activerecord/lib/active_record/validations.rb:736:in `save!'
>>      /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/
>> activerecord/lib/active_record/validations.rb:699:in `create!'
>>      article_test.rb.orig:156:in
>> `test_future_publishing_without_published_flag'
>>
>>    5) Failure:
>> test_html_title(ArticleTest) [article_test.rb.orig:63]:
>> <false> is not true.
>>
>>    6) Error:
>> test_just_published_flag(ArticleTest):
>> ActiveRecord::RecordInvalid: Validation failed: Blog can't be blank
>>      /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/
>> activerecord/lib/active_record/validations.rb:736:in `save!'
>>      /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/
>> activerecord/lib/active_record/validations.rb:699:in `create!'
>>      article_test.rb.orig:142:in `test_just_published_flag'
>>
>>    7) Failure:
>> test_notifications(ArticleTest) [article_test.rb.orig:203]:
>> <false> is not true.
>>
>>    8) Failure:
>> test_tags(ArticleTest) [article_test.rb.orig:92]:
>> <false> is not true.
>>
>>    9) Error:
>> test_triggers_are_dependent(ArticleTest):
>> ActiveRecord::RecordInvalid: Validation failed: Blog can't be blank
>>      /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/
>> activerecord/lib/active_record/validations.rb:736:in `save!'
>>      /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/
>> activerecord/lib/active_record/validations.rb:699:in `create!'
>>      article_test.rb.orig:161:in `test_triggers_are_dependent'
>>
>> 21 tests, 45 assertions, 4 failures, 5 errors
>>
>> After:
>>
>> mattrose at venice:~/typotest/typo.sqlite/test/unit$ ruby  
>> article_test.rb
>> Loaded suite article_test
>> Started
>> .....................
>> Finished in 11.862288 seconds.
>>
>> 21 tests, 72 assertions, 0 failures, 0 errors
>>
>> and this is the unified diff
>>
>> --- article_test.rb.orig        2006-06-21 21:51:49.000000000 -0400
>> +++ article_test.rb     2006-06-21 21:57:34.000000000 -0400
>> @@ -18,6 +18,7 @@
>>     def test_create
>>       a = Article.new
>> +               a.blog_id = 1
>>       a.user_id = 1
>>       a.body = "Foo"
>>       a.title = "Zzz"
>> @@ -60,6 +61,7 @@
>>     def test_html_title
>>       a = Article.new
>>       a.title = "This <i>is</i> a <b>test</b>"
>> +               a.blog_id = 1
>>       assert a.save
>>       assert_equal 'this-is-a-test', a.permalink
>> @@ -79,7 +81,7 @@
>>     end
>>     def test_tags
>> -    a = Article.new(:title => 'Test tag article',
>> +    a = Article.new(:title => 'Test tag article', :blog_id => 1,
>>                       :keywords => 'test tag tag stuff');
>>       assert_kind_of Article, a
>> @@ -139,7 +141,7 @@
>>       assert art.save
>>       assert !art.just_published?
>> -    art = Article.create!(:title => 'title2',
>> +    art = Article.create!(:title => 'title2', :blog_id => 2,
>>                             :body => 'body',
>>                             :published => false)
>> @@ -148,17 +150,18 @@
>>     def test_future_publishing
>>       assert_sets_trigger(Article.create!(:title => 'title', :body =>
>> 'body',
>> +
>>
>>                   :blog_id => 1,
>>                                           :published => true,
>>                                           :published_at => Time.now +
>> 2.seconds))
>>     end
>>     def test_future_publishing_without_published_flag
>> -    assert_sets_trigger Article.create!(:title => 'title', :body =>
>> 'body',
>> +    assert_sets_trigger Article.create!(:title => 'title', :body =>
>> 'body', :blog_id => 1,
>>                                           :published_at => Time.now +
>> 2.seconds)
>>     end
>>     def test_triggers_are_dependent
>> -    art = Article.create!(:title => 'title', :body => 'body',
>> +    art = Article.create!(:title => 'title', :body =>
>> 'body', :blog_id => 1,
>>                             :published_at => Time.now + 1.hour)
>>       assert_equal 1, Trigger.count
>>       art.destroy
>> @@ -178,8 +181,10 @@
>>       Article.create!(:title      => "News from the future!",
>>                       :body       => "The future is cool!",
>>                       :keywords   => "future",
>> +
>>          :blog_id                => 1,
>>                       :published_at => Time.now + 12.minutes)
>> +               #print @articles.find(/future/)
>>       @articles = Category.find_by_permalink
>> ('personal').published_articles
>>       assert_results_are :article1, :article2, :article3
>> @@ -199,7 +204,7 @@
>>     end
>>     def test_notifications
>> -    a = Article.new(:title => 'New Article', :body => 'Foo', :author
>> => 'Tobi', :user => users(:tobi))
>> +    a = Article.new(:title => 'New Article', :blog_id => 1, :body =>
>> 'Foo', :author => 'Tobi', :user => users(:tobi))
>>       assert a.save
>>       assert_equal 2, a.notify_users.size
>>
>>
>>
>> On 21-Jun-06, at 9:32 PM, Matt Rose wrote:
>>
>>>
>>> So I finally got a start on figuring out why tests were failing.  It
>>> looks like none of the tests have been updated since the "blogs"
>>> table was added, as I keep getting this error on the tests
>>>
>>>    2) Error:
>>> test_just_published_flag(ArticleTest):
>>> ActiveRecord::RecordInvalid: Validation failed: Blog can't be blank
>>>      /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/
>>> activerecord/lib/active_record/validations.rb:736:in `save!'
>>>      /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/
>>> activerecord/lib/active_record/validations.rb:699:in `create!'
>>>      article_test.rb:144:in `test_just_published_flag'
>>>
>>> and everytime I add the "blog_id" to the the article that gets
>>> created in the test (I'm running through article tests right now)  
>>> the
>>> test passes.
>>>
>>> However, this doesn't really jibe with what everyone else is saying
>>> on the list, as those tests shouldn't be passing for anyone.
>>>
>>> Matt
>>>
>>> On 21-Jun-06, at 2:11 AM, Piers Cawley wrote:
>>>
>>>> Matt Rose <mattrose at folkwolf.net> writes:
>>>>
>>>>> So I've been looking into the built in unit tests in typo, and I
>>>>> figured
>>>>> out how to run them.
>>>>
>>>> Umm... have you run 'rake migrate'? ISTR that the schema in the  
>>>> trunk
>>>> doesn't exactly tally with the migrations. Which could explain your
>>>> failures.
>>>>
>>>> --
>>>> Piers Cawley <pdcawley at bofh.org.uk>
>>>> http://www.bofh.org.uk/
>>>> _______________________________________________
>>>> Typo-list mailing list
>>>> Typo-list at rubyforge.org
>>>> http://rubyforge.org/mailman/listinfo/typo-list
>>>
>>> _______________________________________________
>>> Typo-list mailing list
>>> Typo-list at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/typo-list
>>
>> _______________________________________________
>> Typo-list mailing list
>> Typo-list at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/typo-list
>>
> _______________________________________________
> Typo-list mailing list
> Typo-list at rubyforge.org
> http://rubyforge.org/mailman/listinfo/typo-list



More information about the Typo-list mailing list