assert_select "body", :count => 1 do
assert_select "div.wrapper", :count => 1 do
assert_select "div.content-heading", :count => 1 do
- assert_select "h2", :text => /#{entry.user.display_name}'s diary/, :count => 1
+ assert_select "h2", :text => /#{entry.user.display_name}'s diary/, :count => 1
end
assert_select "div#content", :count => 1 do
assert_select "div.post_heading", :text => /#{new_title}/, :count => 1
assert_select "body", :count => 1 do
assert_select "div.wrapper", :count => 1 do
assert_select "div.content-heading", :count => 1 do
- assert_select "h2", :text => /#{users(:normal_user).display_name}'s diary/, :count => 1
+ assert_select "h2", :text => /#{users(:normal_user).display_name}'s diary/, :count => 1
end
assert_select "div#content", :count => 1 do
assert_select "div.post_heading", :text => /#{new_title}/, :count => 1
assert_response :success
assert_template 'view'
end
+
+ def test_hide
+ # Try without logging in
+ post :hide, {:display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_entry_1).id}
+ assert_response :forbidden
+ assert_equal true, DiaryEntry.find(diary_entries(:normal_user_entry_1).id).visible
+
+ @request.cookies["_osm_username"] = users(:normal_user).display_name
+
+ # Now try as a normal user
+ post :hide, {:display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_entry_1).id}, {:user => users(:normal_user).id}
+ assert_response :redirect
+ assert_redirected_to :action => :view, :display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_entry_1).id
+ assert_equal true, DiaryEntry.find(diary_entries(:normal_user_entry_1).id).visible
+
+ @request.cookies["_osm_username"] = users(:administrator_user).display_name
+
+ # Finally try as an administrator
+ post :hide, {:display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_entry_1).id}, {:user => users(:administrator_user).id}
+ assert_response :redirect
+ assert_redirected_to :action => :list, :display_name => users(:normal_user).display_name
+ assert_equal false, DiaryEntry.find(diary_entries(:normal_user_entry_1).id).visible
+ end
+
+ def test_hidecomment
+ # Try without logging in
+ post :hidecomment, {:display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_geo_entry).id, :comment => diary_comments(:comment_for_geo_post).id}
+ assert_response :forbidden
+ assert_equal true, DiaryComment.find(diary_comments(:comment_for_geo_post).id).visible
+
+ @request.cookies["_osm_username"] = users(:normal_user).display_name
+
+ # Now try as a normal user
+ post :hidecomment, {:display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_geo_entry).id, :comment => diary_comments(:comment_for_geo_post).id}, {:user => users(:normal_user).id}
+ assert_response :redirect
+ assert_redirected_to :action => :view, :display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_geo_entry).id
+ assert_equal true, DiaryComment.find(diary_comments(:comment_for_geo_post).id).visible
+
+ @request.cookies["_osm_username"] = users(:administrator_user).display_name
+
+ # Finally try as an administrator
+ post :hidecomment, {:display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_geo_entry).id, :comment => diary_comments(:comment_for_geo_post).id}, {:user => users(:administrator_user).id}
+ assert_response :redirect
+ assert_redirected_to :action => :view, :display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_geo_entry).id
+ assert_equal false, DiaryComment.find(diary_comments(:comment_for_geo_post).id).visible
+ end
end