Skip to content

Commit

Permalink
Added another test to ensure new_notes accessor works.
Browse files Browse the repository at this point in the history
git-svn-id: http://substruct.googlecode.com/svn/trunk/plugins/substruct@163 6a1f77cc-a145-0410-afd8-bd7963fcc59f
  • Loading branch information
subimage committed Nov 3, 2008
1 parent 574dab3 commit 32a8829
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/models/order.rb
Expand Up @@ -148,6 +148,7 @@ def set_new_notes()
new_note << "<span class=\"info\">"
new_note << "[#{time}]"
new_note << "</span></p>"
self.notes ||= ''
write_attribute(:notes, self.notes + new_note)
self.new_notes = nil
end
Expand Down
10 changes: 7 additions & 3 deletions test/unit/order_test.rb
Expand Up @@ -648,13 +648,17 @@ def test_get_all_line_items_total
assert_equal an_order.line_items_total, an_order.order_line_items.collect{ |p| p.unit_price * p.quantity }.sum
end


def test_new_notes_update_attr
notes_before = @santa_order.notes.dup
# Notes need to be NIL in order to test an edge case error.
@santa_order.update_attribute(:notes, nil)
# ^^ DONT REMOVE THIS
@santa_order.update_attributes({
:new_notes => 'Hello world.'
})
notes_after = @santa_order.reload.notes
assert_not_equal notes_before, notes_after
@santa_order.reload
assert_not_nil @santa_order.notes
assert @santa_order.notes.include?("<span class=\"info\">")
end

# Test an order to see if the correct total weight will be returned.
Expand Down

0 comments on commit 32a8829

Please sign in to comment.