Skip to content

Commit

Permalink
fix article spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerome Stonebridge committed Apr 5, 2011
1 parent f473382 commit 5176f62
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion doc/NOTES
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ add example.com 127.0.0.1 and test.example.com 127.0.0.1 to your hosts file. St

add blogs to admin user hash

48 failing specs, 9 pending
41 failing specs, 9 pending


----------------
Expand Down
20 changes: 12 additions & 8 deletions spec/models/article_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
describe Article do

before do
Factory(:blog)
@blog = Factory(:blog)
@articles = []
end

Expand Down Expand Up @@ -76,6 +76,7 @@ def assert_results_are(*expected)
a.user_id = 1
a.body = "Foo"
a.title = "Zzz"
a.blog_id = @blog.id
assert a.save

a.categories << Category.find(Factory(:category).id)
Expand Down Expand Up @@ -112,6 +113,7 @@ def assert_results_are(*expected)
it "test_html_title" do
a = Article.new
a.title = "This <i>is</i> a <b>test</b>"
a.blog_id = @blog.id
assert a.save

assert_equal 'this-is-a-test', a.permalink
Expand All @@ -120,6 +122,7 @@ def assert_results_are(*expected)
it "does not escape multibyte characters in the autogenerated permalink" do
a = Article.new
a.title = "ルビー"
a.blog_id = @blog.id
assert a.save

a.permalink.should == "ルビー"
Expand Down Expand Up @@ -217,33 +220,33 @@ def assert_results_are(*expected)

it "test_just_published_flag" do

art = Article.new(:title => 'title', :body => 'body', :published => true)
art = Article.new(:title => 'title', :body => 'body', :published => true, :blog_id => @blog.id)

assert art.just_changed_published_status?
assert art.save

art = Article.find(art.id)
assert !art.just_changed_published_status?

art = Article.create!(:title => 'title2', :body => 'body', :published => false)
art = Article.create!(:title => 'title2', :body => 'body', :published => false, :blog_id => @blog.id)

assert ! art.just_changed_published_status?
end

it "test_future_publishing" do
assert_sets_trigger(Article.create!(:title => 'title', :body => 'body',
:published => true, :published_at => Time.now + 4.seconds))
:published => true, :published_at => Time.now + 4.seconds, :blog_id => @blog.id))
end

it "test_future_publishing_without_published_flag" do
assert_sets_trigger Article.create!(:title => 'title', :body => 'body',
:published_at => Time.now + 4.seconds)
:published_at => Time.now + 4.seconds, :blog_id => @blog.id)
end

it "test_triggers_are_dependent" do
pending "Needs a fix for Rails ticket #5105: has_many: Dependent deleting does not work with STI"
art = Article.create!(:title => 'title', :body => 'body',
:published_at => Time.now + 1.hour)
:published_at => Time.now + 1.hour, :blog_id => @blog.id)
assert_equal 1, Trigger.count
art.destroy
assert_equal 0, Trigger.count
Expand Down Expand Up @@ -274,7 +277,8 @@ def assert_sets_trigger(art)
Article.create!(:title => "News from the future!",
:body => "The future is cool!",
:keywords => "future",
:published_at => Time.now + 12.minutes)
:published_at => Time.now + 12.minutes,
:blog_id => @blog.id)

articles = Category.find_by_permalink('personal').published_articles
assert_equal 3, articles.size
Expand Down Expand Up @@ -304,7 +308,7 @@ def assert_sets_trigger(art)
[:randomuser, :bob].each do |tag|
u = users(tag); u.notify_on_new_articles = true; u.save!
end
a = Article.new(:title => 'New Article', :body => 'Foo', :author => 'Tobi', :user => users(:tobi))
a = Article.new(:title => 'New Article', :body => 'Foo', :author => 'Tobi', :user => users(:tobi), :blog_id => @blog.id)
assert a.save

assert_equal 2, a.notify_users.size
Expand Down

0 comments on commit 5176f62

Please sign in to comment.