Commit 3d5b46501aa593f9fa2fc0be2fe7210f63e6142b
1 parent
045fbc74
Exists in
staging
and in
42 other branches
rails3: fix mass-assignment on scrap test
Also discovered that the ActionTracker::Record.current_user_from_model returning nil is a bug. So I'm removing the stubs I did before.
Showing
2 changed files
with
7 additions
and
9 deletions
Show diff stats
test/unit/scrap_test.rb
| ... | ... | @@ -215,7 +215,7 @@ class ScrapTest < ActiveSupport::TestCase |
| 215 | 215 | s = fast_create(Scrap, :updated_at => DateTime.parse('2010-01-01')) |
| 216 | 216 | assert_equal DateTime.parse('2010-01-01'), s.updated_at.strftime('%Y-%m-%d') |
| 217 | 217 | DateTime.stubs(:now).returns(DateTime.parse('2010-09-07')) |
| 218 | - s1 = Scrap.create(defaults_for_scrap(:scrap_id => s.id)) | |
| 218 | + s1 = create(Scrap, defaults_for_scrap(:scrap_id => s.id)) | |
| 219 | 219 | s.reload |
| 220 | 220 | assert_not_equal DateTime.parse('2010-01-01'), s.updated_at.strftime('%Y-%m-%d') |
| 221 | 221 | end |
| ... | ... | @@ -230,20 +230,20 @@ class ScrapTest < ActiveSupport::TestCase |
| 230 | 230 | |
| 231 | 231 | should 'strip all html tags' do |
| 232 | 232 | s, r = fast_create(Person), fast_create(Person) |
| 233 | - s = Scrap.new :sender => s, :receiver => r, :content => "<p>Test <b>Rails</b></p>" | |
| 233 | + s = build Scrap, :sender => s, :receiver => r, :content => "<p>Test <b>Rails</b></p>" | |
| 234 | 234 | assert_equal "Test Rails", s.strip_all_html_tags |
| 235 | 235 | end |
| 236 | 236 | |
| 237 | 237 | should 'strip html before save' do |
| 238 | 238 | s, r = fast_create(Person), fast_create(Person) |
| 239 | - s = Scrap.new :sender => s, :receiver => r, :content => "<p>Test <b>Rails</b></p>" | |
| 239 | + s = build Scrap, :sender => s, :receiver => r, :content => "<p>Test <b>Rails</b></p>" | |
| 240 | 240 | s.save! |
| 241 | 241 | assert_equal "Test Rails", s.reload.content |
| 242 | 242 | end |
| 243 | 243 | |
| 244 | 244 | should 'strip html before validate' do |
| 245 | 245 | s, r = fast_create(Person), fast_create(Person) |
| 246 | - s = Scrap.new :sender => s, :receiver => r, :content => "<p><b></b></p>" | |
| 246 | + s = build Scrap, :sender => s, :receiver => r, :content => "<p><b></b></p>" | |
| 247 | 247 | assert !s.valid? |
| 248 | 248 | s.content = "<p>Test</p>" |
| 249 | 249 | assert s.valid? |
| ... | ... | @@ -260,15 +260,15 @@ class ScrapTest < ActiveSupport::TestCase |
| 260 | 260 | |
| 261 | 261 | should 'scrap wall url be the root scrap receiver url if it is a reply' do |
| 262 | 262 | p1, p2 = fast_create(Person), fast_create(Person) |
| 263 | - r = Scrap.create! :sender => p1, :receiver => p2, :content => "Hello!" | |
| 264 | - s = Scrap.new :sender => p2, :receiver => p1, :content => "Hi!" | |
| 263 | + r = create Scrap, :sender => p1, :receiver => p2, :content => "Hello!" | |
| 264 | + s = build Scrap, :sender => p2, :receiver => p1, :content => "Hi!" | |
| 265 | 265 | r.replies << s; s.reload |
| 266 | 266 | assert_equal s.scrap_wall_url, s.root.receiver.wall_url |
| 267 | 267 | end |
| 268 | 268 | |
| 269 | 269 | should 'scrap wall url be the scrap receiver url if it is not a reply' do |
| 270 | 270 | p1, p2 = fast_create(Person), fast_create(Person) |
| 271 | - s = Scrap.create! :sender => p1, :receiver => p2, :content => "Hello!" | |
| 271 | + s = create Scrap, :sender => p1, :receiver => p2, :content => "Hello!" | |
| 272 | 272 | assert_equal s.scrap_wall_url, s.receiver.wall_url |
| 273 | 273 | end |
| 274 | 274 | ... | ... |
test/unit/tiny_mce_article_test.rb
| ... | ... | @@ -142,7 +142,6 @@ class TinyMceArticleTest < ActiveSupport::TestCase |
| 142 | 142 | should 'not update activity on update of an article' do |
| 143 | 143 | ActionTracker::Record.delete_all |
| 144 | 144 | profile = fast_create(Profile) |
| 145 | - ActionTracker::Record.stubs(:current_user_from_model).returns(fast_create(Person)) | |
| 146 | 145 | article = create(TinyMceArticle, :profile_id => profile.id) |
| 147 | 146 | time = article.activity.updated_at |
| 148 | 147 | Time.stubs(:now).returns(time + 1.day) |
| ... | ... | @@ -186,7 +185,6 @@ end |
| 186 | 185 | should "the tracker action target be defined as the article on articles'creation in profile" do |
| 187 | 186 | ActionTracker::Record.delete_all |
| 188 | 187 | person = Person.first |
| 189 | - ActionTracker::Record.stubs(:current_user_from_model).returns(fast_create(Person)) | |
| 190 | 188 | article = create TinyMceArticle, :name => 'test', :profile_id => person.id |
| 191 | 189 | assert_equal article, ActionTracker::Record.last.target |
| 192 | 190 | end | ... | ... |