diff --git a/app/models/post.rb b/app/models/post.rb
index 1e0888716..5928f0b42 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -216,7 +216,7 @@ class Post < ActiveRecord::Base
module ApprovalMethods
def is_approvable?
- (is_pending? || is_flagged?) && approver_string != "approver:#{CurrentUser.name}"
+ (is_pending? || is_flagged? || is_deleted?) && approver_string != "approver:#{CurrentUser.name}"
end
def flag!(reason)
@@ -240,8 +240,10 @@ class Post < ActiveRecord::Base
def approve!
raise ApprovalError.new("You have previously approved this post and cannot approve it again") if approver_string == "approver:#{CurrentUser.name}"
+ flags.each {|x| x.resolve!}
self.is_flagged = false
self.is_pending = false
+ self.is_deleted = false
self.approver_string = "approver:#{CurrentUser.name}"
save!
end
diff --git a/app/models/post_flag.rb b/app/models/post_flag.rb
index 681e5fc41..c7ddcbf7e 100644
--- a/app/models/post_flag.rb
+++ b/app/models/post_flag.rb
@@ -7,15 +7,17 @@ class PostFlag < ActiveRecord::Base
validate :validate_creator_is_not_limited
validate :validate_post_is_active
before_validation :initialize_creator, :on => :create
- validates_uniqueness_of :creator_id, :scope => :post_id
+ validates_uniqueness_of :creator_id, :scope => :post_id, :message => "has already flagged this post"
before_save :update_post
+ scope :resolved, where(["is_resolved = ?", true])
+ scope :unresolved, where(["is_resolved = ?", false])
def update_post
post.update_attribute(:is_flagged, true)
end
def validate_creator_is_not_limited
- if PostAppeal.for_user(creator_id).recent.count >= 10
+ if flag_count_for_creator >= 10
errors[:creator] << "can flag 10 posts a day"
false
else
@@ -36,4 +38,12 @@ class PostFlag < ActiveRecord::Base
self.creator_id = CurrentUser.id
self.creator_ip_addr = CurrentUser.ip_addr
end
+
+ def resolve!
+ update_attribute(:is_resolved, true)
+ end
+
+ def flag_count_for_creator
+ PostAppeal.for_user(creator_id).recent.count
+ end
end
diff --git a/app/views/posts/partials/show/_notices.html.erb b/app/views/posts/partials/show/_notices.html.erb
index 051970d4b..e311af82d 100644
--- a/app/views/posts/partials/show/_notices.html.erb
+++ b/app/views/posts/partials/show/_notices.html.erb
@@ -1,4 +1,4 @@
-<% if post.is_flagged? %>
+<% if (post.is_flagged? || post.is_deleted?) && post.flags.any? %>
This post has been flagged for deletion: <%= post_flag_reasons(post) %>
diff --git a/db/development_structure.sql b/db/development_structure.sql
index 651a1a1ed..228244488 100644
--- a/db/development_structure.sql
+++ b/db/development_structure.sql
@@ -1013,6 +1013,40 @@ CREATE SEQUENCE pools_id_seq
ALTER SEQUENCE pools_id_seq OWNED BY pools.id;
+--
+-- Name: post_appeals; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE post_appeals (
+ id integer NOT NULL,
+ post_id integer NOT NULL,
+ creator_id integer NOT NULL,
+ creator_ip_addr integer NOT NULL,
+ reason text,
+ created_at timestamp without time zone,
+ updated_at timestamp without time zone
+);
+
+
+--
+-- Name: post_appeals_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE post_appeals_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MAXVALUE
+ NO MINVALUE
+ CACHE 1;
+
+
+--
+-- Name: post_appeals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE post_appeals_id_seq OWNED BY post_appeals.id;
+
+
--
-- Name: post_disapprovals; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@@ -1045,6 +1079,40 @@ CREATE SEQUENCE post_disapprovals_id_seq
ALTER SEQUENCE post_disapprovals_id_seq OWNED BY post_disapprovals.id;
+--
+-- Name: post_flags; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE post_flags (
+ id integer NOT NULL,
+ post_id integer NOT NULL,
+ creator_id integer NOT NULL,
+ creator_ip_addr inet NOT NULL,
+ reason text,
+ created_at timestamp without time zone,
+ updated_at timestamp without time zone
+);
+
+
+--
+-- Name: post_flags_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE post_flags_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MAXVALUE
+ NO MINVALUE
+ CACHE 1;
+
+
+--
+-- Name: post_flags_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE post_flags_id_seq OWNED BY post_flags.id;
+
+
--
-- Name: post_versions; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@@ -1750,6 +1818,13 @@ ALTER TABLE pool_versions ALTER COLUMN id SET DEFAULT nextval('pool_versions_id_
ALTER TABLE pools ALTER COLUMN id SET DEFAULT nextval('pools_id_seq'::regclass);
+--
+-- Name: id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE post_appeals ALTER COLUMN id SET DEFAULT nextval('post_appeals_id_seq'::regclass);
+
+
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
@@ -1757,6 +1832,13 @@ ALTER TABLE pools ALTER COLUMN id SET DEFAULT nextval('pools_id_seq'::regclass);
ALTER TABLE post_disapprovals ALTER COLUMN id SET DEFAULT nextval('post_disapprovals_id_seq'::regclass);
+--
+-- Name: id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE post_flags ALTER COLUMN id SET DEFAULT nextval('post_flags_id_seq'::regclass);
+
+
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
@@ -2072,6 +2154,14 @@ ALTER TABLE ONLY pools
ADD CONSTRAINT pools_pkey PRIMARY KEY (id);
+--
+-- Name: post_appeals_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY post_appeals
+ ADD CONSTRAINT post_appeals_pkey PRIMARY KEY (id);
+
+
--
-- Name: post_disapprovals_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@@ -2080,6 +2170,14 @@ ALTER TABLE ONLY post_disapprovals
ADD CONSTRAINT post_disapprovals_pkey PRIMARY KEY (id);
+--
+-- Name: post_flags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY post_flags
+ ADD CONSTRAINT post_flags_pkey PRIMARY KEY (id);
+
+
--
-- Name: post_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@@ -2639,6 +2737,27 @@ CREATE INDEX index_pools_on_creator_id ON pools USING btree (creator_id);
CREATE INDEX index_pools_on_name ON pools USING btree (name);
+--
+-- Name: index_post_appeals_on_creator_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_post_appeals_on_creator_id ON post_appeals USING btree (creator_id);
+
+
+--
+-- Name: index_post_appeals_on_creator_ip_addr; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_post_appeals_on_creator_ip_addr ON post_appeals USING btree (creator_ip_addr);
+
+
+--
+-- Name: index_post_appeals_on_post_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_post_appeals_on_post_id ON post_appeals USING btree (post_id);
+
+
--
-- Name: index_post_disapprovals_on_post_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@@ -2653,6 +2772,27 @@ CREATE INDEX index_post_disapprovals_on_post_id ON post_disapprovals USING btree
CREATE INDEX index_post_disapprovals_on_user_id ON post_disapprovals USING btree (user_id);
+--
+-- Name: index_post_flags_on_creator_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_post_flags_on_creator_id ON post_flags USING btree (creator_id);
+
+
+--
+-- Name: index_post_flags_on_creator_ip_addr; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_post_flags_on_creator_ip_addr ON post_flags USING btree (creator_ip_addr);
+
+
+--
+-- Name: index_post_flags_on_post_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX index_post_flags_on_post_id ON post_flags USING btree (post_id);
+
+
--
-- Name: index_post_versions_on_post_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@@ -3009,4 +3149,8 @@ INSERT INTO schema_migrations (version) VALUES ('20100309211553');
INSERT INTO schema_migrations (version) VALUES ('20100318213503');
-INSERT INTO schema_migrations (version) VALUES ('20100826232512');
\ No newline at end of file
+INSERT INTO schema_migrations (version) VALUES ('20100826232512');
+
+INSERT INTO schema_migrations (version) VALUES ('20110328215652');
+
+INSERT INTO schema_migrations (version) VALUES ('20110328215701');
\ No newline at end of file
diff --git a/db/migrate/20110328215652_create_post_flags.rb b/db/migrate/20110328215652_create_post_flags.rb
index 03b6f4605..b151acc1a 100644
--- a/db/migrate/20110328215652_create_post_flags.rb
+++ b/db/migrate/20110328215652_create_post_flags.rb
@@ -5,6 +5,7 @@ class CreatePostFlags < ActiveRecord::Migration
t.column :creator_id, :integer, :null => false
t.column :creator_ip_addr, :inet, :null => false
t.column :reason, :text
+ t.column :is_resolved, :boolean, :null => false, :default => false
t.timestamps
end
diff --git a/test/unit/helpers/admin/users_helper_test.rb b/test/unit/helpers/admin/users_helper_test.rb
deleted file mode 100644
index 1b59e3d97..000000000
--- a/test/unit/helpers/admin/users_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class Admin::UsersHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/advertisements_helper_test.rb b/test/unit/helpers/advertisements_helper_test.rb
deleted file mode 100644
index 275aa95ab..000000000
--- a/test/unit/helpers/advertisements_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class AdvertisementsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/artist_versions_helper_test.rb b/test/unit/helpers/artist_versions_helper_test.rb
deleted file mode 100644
index 5c945706c..000000000
--- a/test/unit/helpers/artist_versions_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class ArtistVersionsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/artists_helper_test.rb b/test/unit/helpers/artists_helper_test.rb
deleted file mode 100644
index 091990447..000000000
--- a/test/unit/helpers/artists_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class ArtistsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/bans_helper_test.rb b/test/unit/helpers/bans_helper_test.rb
deleted file mode 100644
index eaa6fcad8..000000000
--- a/test/unit/helpers/bans_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class BansHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/comment_votes_helper_test.rb b/test/unit/helpers/comment_votes_helper_test.rb
deleted file mode 100644
index d64ce1917..000000000
--- a/test/unit/helpers/comment_votes_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class CommentVotesHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/comments_helper_test.rb b/test/unit/helpers/comments_helper_test.rb
deleted file mode 100644
index 2518c16bd..000000000
--- a/test/unit/helpers/comments_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class CommentsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/dmails_helper_test.rb b/test/unit/helpers/dmails_helper_test.rb
deleted file mode 100644
index a0f8cb246..000000000
--- a/test/unit/helpers/dmails_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class DmailsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/favorites_helper_test.rb b/test/unit/helpers/favorites_helper_test.rb
deleted file mode 100644
index fabd87cb5..000000000
--- a/test/unit/helpers/favorites_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class FavoritesHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/forum_posts_helper_test.rb b/test/unit/helpers/forum_posts_helper_test.rb
deleted file mode 100644
index 79a6a205d..000000000
--- a/test/unit/helpers/forum_posts_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class ForumPostsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/forum_topics_helper_test.rb b/test/unit/helpers/forum_topics_helper_test.rb
deleted file mode 100644
index 44dddfa85..000000000
--- a/test/unit/helpers/forum_topics_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class ForumTopicsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/janitor_trials_helper_test.rb b/test/unit/helpers/janitor_trials_helper_test.rb
deleted file mode 100644
index 89ea318e6..000000000
--- a/test/unit/helpers/janitor_trials_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class JanitorTrialsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/notes_helper_test.rb b/test/unit/helpers/notes_helper_test.rb
deleted file mode 100644
index 4984103c7..000000000
--- a/test/unit/helpers/notes_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class NotesHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/pool_versions_helper_test.rb b/test/unit/helpers/pool_versions_helper_test.rb
deleted file mode 100644
index 9998c4d34..000000000
--- a/test/unit/helpers/pool_versions_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class PoolVersionsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/pools_helper_test.rb b/test/unit/helpers/pools_helper_test.rb
deleted file mode 100644
index 326ce3101..000000000
--- a/test/unit/helpers/pools_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class PoolsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/post_helper_test.rb b/test/unit/helpers/post_helper_test.rb
deleted file mode 100644
index 0dcd1a16d..000000000
--- a/test/unit/helpers/post_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class PostHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/post_moderation_details_helper_test.rb b/test/unit/helpers/post_moderation_details_helper_test.rb
deleted file mode 100644
index c16d66e50..000000000
--- a/test/unit/helpers/post_moderation_details_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class PostModerationDetailsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/post_versions_helper_test.rb b/test/unit/helpers/post_versions_helper_test.rb
deleted file mode 100644
index c64f662fe..000000000
--- a/test/unit/helpers/post_versions_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class PostVersionsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/post_votes_helper_test.rb b/test/unit/helpers/post_votes_helper_test.rb
deleted file mode 100644
index 56a91f1ba..000000000
--- a/test/unit/helpers/post_votes_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class PostVotesHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/sessions_helper_test.rb b/test/unit/helpers/sessions_helper_test.rb
deleted file mode 100644
index 7d44e0965..000000000
--- a/test/unit/helpers/sessions_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class SessionsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/tag_aliases_helper_test.rb b/test/unit/helpers/tag_aliases_helper_test.rb
deleted file mode 100644
index 14032c642..000000000
--- a/test/unit/helpers/tag_aliases_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class TagAliasesHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/tag_implications_helper_test.rb b/test/unit/helpers/tag_implications_helper_test.rb
deleted file mode 100644
index e7f53afeb..000000000
--- a/test/unit/helpers/tag_implications_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class TagImplicationsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/tag_subscriptions_helper_test.rb b/test/unit/helpers/tag_subscriptions_helper_test.rb
deleted file mode 100644
index 40a713ae7..000000000
--- a/test/unit/helpers/tag_subscriptions_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class TagSubscriptionsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/tags_helper_test.rb b/test/unit/helpers/tags_helper_test.rb
deleted file mode 100644
index 4b1935f8f..000000000
--- a/test/unit/helpers/tags_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class TagsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/unapprovals_helper_test.rb b/test/unit/helpers/unapprovals_helper_test.rb
deleted file mode 100644
index 45980441f..000000000
--- a/test/unit/helpers/unapprovals_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class UnapprovalsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/uploads_helper_test.rb b/test/unit/helpers/uploads_helper_test.rb
deleted file mode 100644
index 37ed90b83..000000000
--- a/test/unit/helpers/uploads_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class UploadsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/user_feedback_helper_test.rb b/test/unit/helpers/user_feedback_helper_test.rb
deleted file mode 100644
index f921ddbee..000000000
--- a/test/unit/helpers/user_feedback_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class UserFeedbackHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/users_helper_test.rb b/test/unit/helpers/users_helper_test.rb
deleted file mode 100644
index 96af37a82..000000000
--- a/test/unit/helpers/users_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class UsersHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/wiki_page_versions_helper_test.rb b/test/unit/helpers/wiki_page_versions_helper_test.rb
deleted file mode 100644
index 9414ffc57..000000000
--- a/test/unit/helpers/wiki_page_versions_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class WikiPageVersionsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/wiki_pages_helper_test.rb b/test/unit/helpers/wiki_pages_helper_test.rb
deleted file mode 100644
index 74e23ae17..000000000
--- a/test/unit/helpers/wiki_pages_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class WikiPagesHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/post_flag_test.rb b/test/unit/post_flag_test.rb
index 0b536a6fe..5a51297af 100644
--- a/test/unit/post_flag_test.rb
+++ b/test/unit/post_flag_test.rb
@@ -1,8 +1,57 @@
require 'test_helper'
class PostFlagTest < ActiveSupport::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
+ context "In all cases" do
+ setup do
+ @alice = Factory.create(:user)
+ CurrentUser.user = @alice
+ CurrentUser.ip_addr = "127.0.0.1"
+ MEMCACHE.flush_all
+ end
+
+ teardown do
+ CurrentUser.user = nil
+ CurrentUser.ip_addr = nil
+ end
+
+ context "a user" do
+ setup do
+ @post = Factory.create(:post, :tag_string => "aaa")
+ end
+
+ should "not be able to flag a post more than twice" do
+ assert_difference("PostFlag.count", 1) do
+ @post_flag = PostFlag.create(:post => @post, :reason => "aaa")
+ end
+
+ assert_difference("PostFlag.count", 0) do
+ @post_flag = PostFlag.create(:post => @post, :reason => "aaa")
+ end
+
+ assert_equal(["Creator has already flagged this post"], @post_flag.errors.full_messages)
+ end
+
+ should "not be able to flag more than 10 posts in 24 hours" do
+ @post_flag = PostFlag.new(:post => @post, :reason => "aaa")
+ @post_flag.expects(:flag_count_for_creator).returns(10)
+ assert_difference("PostFlag.count", 0) do
+ @post_flag.save
+ end
+ assert_equal(["Creator can flag 10 posts a day"], @post_flag.errors.full_messages)
+ end
+
+ should "not be able to flag a deleted post" do
+ @post.update_attribute(:is_deleted, true)
+ assert_difference("PostFlag.count", 0) do
+ @post_flag = PostFlag.create(:post => @post, :reason => "aaa")
+ end
+ assert_equal(["Post is deleted"], @post_flag.errors.full_messages)
+ end
+
+ should "initialize its creator" do
+ @post_flag = PostFlag.create(:post => @post, :reason => "aaa")
+ assert_equal(@alice.id, @post_flag.creator_id)
+ end
+ end
end
end