add test case for note

This commit is contained in:
albert
2013-02-23 10:44:42 -05:00
parent 309110b44d
commit 7585462368
2 changed files with 19 additions and 1 deletions

View File

@@ -20,7 +20,7 @@
<tr>
<td></td>
<td><%= link_to note_version.post_id, post_path(note_version.post_id) %></td>
<td><%= link_to "#{note_version.note_id}", note_versions_path(:search => {:note_id => note_version.note_id}) %></td>
<td><%= link_to "#{note_version.note_id}.#{note_version.id}", note_versions_path(:search => {:note_id => note_version.note_id}) %></td>
<td><%= h(note_version.body) %> <% unless note_version.is_active? %>(deleted)<% end %></td>
<td>
<% if CurrentUser.is_janitor? %>

View File

@@ -14,6 +14,24 @@ class NoteTest < ActiveSupport::TestCase
CurrentUser.ip_addr = nil
end
context "for a post that already has a note" do
setup do
@post = FactoryGirl.create(:post)
@note = FactoryGirl.create(:note, :post => @post)
end
context "when the note is deleted the post" do
setup do
@note.toggle!(:is_active)
end
should "null out its last_noted_at_field" do
@post.reload
assert_nil(@post.last_noted_at)
end
end
end
context "creating a note" do
setup do
@post = FactoryGirl.create(:post)