fixes #3007: Eliminate Janitor role
This commit is contained in:
@@ -6,10 +6,6 @@ a.user-moderator.with-style {
|
|||||||
color: orange;
|
color: orange;
|
||||||
}
|
}
|
||||||
|
|
||||||
a.user-janitor.with-style {
|
|
||||||
color: green;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.user-contributor.with-style {
|
a.user-contributor.with-style {
|
||||||
color: purple;
|
color: purple;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ module Admin::UsersHelper
|
|||||||
["Gold", User::Levels::GOLD],
|
["Gold", User::Levels::GOLD],
|
||||||
["Platinum", User::Levels::PLATINUM],
|
["Platinum", User::Levels::PLATINUM],
|
||||||
["Builder", User::Levels::BUILDER],
|
["Builder", User::Levels::BUILDER],
|
||||||
["Janitor", User::Levels::JANITOR],
|
|
||||||
["Moderator", User::Levels::MODERATOR],
|
["Moderator", User::Levels::MODERATOR],
|
||||||
["Admin", User::Levels::ADMIN]
|
["Admin", User::Levels::ADMIN]
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ module Moderator
|
|||||||
["Member", 20],
|
["Member", 20],
|
||||||
["Gold", 30],
|
["Gold", 30],
|
||||||
["Platinum", 31],
|
["Platinum", 31],
|
||||||
["Janitor", 35],
|
|
||||||
["Moderator", 40],
|
["Moderator", 40],
|
||||||
["Admin", 50]
|
["Admin", 50]
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ class AnonymousUser
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
%w(member banned gold builder platinum janitor moderator admin).each do |name|
|
%w(member banned gold builder platinum moderator admin).each do |name|
|
||||||
define_method("is_#{name}?") do
|
define_method("is_#{name}?") do
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ class Artist < ActiveRecord::Base
|
|||||||
has_one :wiki_page, :foreign_key => "title", :primary_key => "name"
|
has_one :wiki_page, :foreign_key => "title", :primary_key => "name"
|
||||||
has_one :tag_alias, :foreign_key => "antecedent_name", :primary_key => "name"
|
has_one :tag_alias, :foreign_key => "antecedent_name", :primary_key => "name"
|
||||||
has_one :tag, :foreign_key => "name", :primary_key => "name"
|
has_one :tag, :foreign_key => "name", :primary_key => "name"
|
||||||
attr_accessible :body, :notes, :name, :url_string, :other_names, :other_names_comma, :group_name, :notes, :as => [:member, :gold, :builder, :platinum, :janitor, :moderator, :default, :admin]
|
attr_accessible :body, :notes, :name, :url_string, :other_names, :other_names_comma, :group_name, :notes, :as => [:member, :gold, :builder, :platinum, :moderator, :default, :admin]
|
||||||
attr_accessible :is_active, :as => [:builder, :janitor, :moderator, :default, :admin]
|
attr_accessible :is_active, :as => [:builder, :moderator, :default, :admin]
|
||||||
attr_accessible :is_banned, :as => :admin
|
attr_accessible :is_banned, :as => :admin
|
||||||
|
|
||||||
scope :active, lambda { where(is_active: true) }
|
scope :active, lambda { where(is_active: true) }
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class Comment < ActiveRecord::Base
|
|||||||
after_update(:if => lambda {|rec| rec.is_deleted? && rec.is_deleted_changed? && CurrentUser.id != rec.creator_id}) do |rec|
|
after_update(:if => lambda {|rec| rec.is_deleted? && rec.is_deleted_changed? && CurrentUser.id != rec.creator_id}) do |rec|
|
||||||
ModAction.log("comment ##{rec.id} deleted by #{CurrentUser.name}")
|
ModAction.log("comment ##{rec.id} deleted by #{CurrentUser.name}")
|
||||||
end
|
end
|
||||||
attr_accessible :body, :post_id, :do_not_bump_post, :is_deleted, :as => [:member, :gold, :platinum, :builder, :janitor, :moderator, :admin]
|
attr_accessible :body, :post_id, :do_not_bump_post, :is_deleted, :as => [:member, :gold, :platinum, :builder, :moderator, :admin]
|
||||||
attr_accessible :is_sticky, :as => [:moderator, :admin]
|
attr_accessible :is_sticky, :as => [:moderator, :admin]
|
||||||
mentionable(
|
mentionable(
|
||||||
:message_field => :body,
|
:message_field => :body,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class DmailFilter < ActiveRecord::Base
|
class DmailFilter < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
attr_accessible :words, :as => [:moderator, :janitor, :gold, :platinum, :member, :anonymous, :default, :builder, :admin]
|
attr_accessible :words, :as => [:moderator, :gold, :platinum, :member, :anonymous, :default, :builder, :admin]
|
||||||
validates_presence_of :user
|
validates_presence_of :user
|
||||||
before_validation :initialize_user
|
before_validation :initialize_user
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class FavoriteGroup < ActiveRecord::Base
|
|||||||
validate :creator_can_create_favorite_groups, :on => :create
|
validate :creator_can_create_favorite_groups, :on => :create
|
||||||
validate :validate_number_of_posts
|
validate :validate_number_of_posts
|
||||||
before_save :update_post_count
|
before_save :update_post_count
|
||||||
attr_accessible :name, :post_ids, :post_id_array, :as => [:member, :gold, :platinum, :builder, :janitor, :moderator, :admin, :default]
|
attr_accessible :name, :post_ids, :post_id_array, :as => [:member, :gold, :platinum, :builder, :moderator, :admin, :default]
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
def for_creator(user_id)
|
def for_creator(user_id)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class ForumPost < ActiveRecord::Base
|
class ForumPost < ActiveRecord::Base
|
||||||
include Mentionable
|
include Mentionable
|
||||||
|
|
||||||
attr_accessible :body, :topic_id, :as => [:member, :builder, :janitor, :gold, :platinum, :admin, :moderator, :default]
|
attr_accessible :body, :topic_id, :as => [:member, :builder, :gold, :platinum, :admin, :moderator, :default]
|
||||||
attr_accessible :is_locked, :is_sticky, :is_deleted, :as => [:admin, :moderator]
|
attr_accessible :is_locked, :is_sticky, :is_deleted, :as => [:admin, :moderator]
|
||||||
attr_readonly :topic_id
|
attr_readonly :topic_id
|
||||||
belongs_to :creator, :class_name => "User"
|
belongs_to :creator, :class_name => "User"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class ForumTopic < ActiveRecord::Base
|
|||||||
Admin: User::Levels::ADMIN,
|
Admin: User::Levels::ADMIN,
|
||||||
}
|
}
|
||||||
|
|
||||||
attr_accessible :title, :original_post_attributes, :category_id, :as => [:member, :builder, :gold, :platinum, :janitor, :moderator, :admin, :default]
|
attr_accessible :title, :original_post_attributes, :category_id, :as => [:member, :builder, :gold, :platinum, :moderator, :admin, :default]
|
||||||
attr_accessible :is_sticky, :is_locked, :is_deleted, :min_level, :as => [:admin, :moderator]
|
attr_accessible :is_sticky, :is_locked, :is_deleted, :min_level, :as => [:admin, :moderator]
|
||||||
belongs_to :creator, :class_name => "User"
|
belongs_to :creator, :class_name => "User"
|
||||||
belongs_to :updater, :class_name => "User"
|
belongs_to :updater, :class_name => "User"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Pool < ActiveRecord::Base
|
|||||||
after_save :create_version
|
after_save :create_version
|
||||||
after_create :synchronize!
|
after_create :synchronize!
|
||||||
before_destroy :create_mod_action_for_destroy
|
before_destroy :create_mod_action_for_destroy
|
||||||
attr_accessible :name, :description, :post_ids, :post_id_array, :post_count, :is_active, :category, :as => [:member, :gold, :platinum, :janitor, :moderator, :admin, :default]
|
attr_accessible :name, :description, :post_ids, :post_id_array, :post_count, :is_active, :category, :as => [:member, :gold, :platinum, :moderator, :admin, :default]
|
||||||
attr_accessible :is_deleted, :as => [:moderator, :admin]
|
attr_accessible :is_deleted, :as => [:moderator, :admin]
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ class Post < ActiveRecord::Base
|
|||||||
has_many :versions, lambda {order("post_versions.updated_at ASC")}, :class_name => "PostArchive", :dependent => :destroy
|
has_many :versions, lambda {order("post_versions.updated_at ASC")}, :class_name => "PostArchive", :dependent => :destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessible :source, :rating, :tag_string, :old_tag_string, :old_parent_id, :old_source, :old_rating, :parent_id, :has_embedded_notes, :as => [:member, :builder, :gold, :platinum, :janitor, :moderator, :admin, :default]
|
attr_accessible :source, :rating, :tag_string, :old_tag_string, :old_parent_id, :old_source, :old_rating, :parent_id, :has_embedded_notes, :as => [:member, :builder, :gold, :platinum, :moderator, :admin, :default]
|
||||||
attr_accessible :is_rating_locked, :is_note_locked, :as => [:builder, :janitor, :moderator, :admin]
|
attr_accessible :is_rating_locked, :is_note_locked, :as => [:builder, :moderator, :admin]
|
||||||
attr_accessible :is_status_locked, :as => [:admin]
|
attr_accessible :is_status_locked, :as => [:admin]
|
||||||
attr_accessor :old_tag_string, :old_parent_id, :old_source, :old_rating, :has_constraints, :disable_versioning, :view_count
|
attr_accessor :old_tag_string, :old_parent_id, :old_source, :old_rating, :has_constraints, :disable_versioning, :view_count
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class Tag < ActiveRecord::Base
|
|||||||
COSINE_SIMILARITY_RELATED_TAG_THRESHOLD = 1000
|
COSINE_SIMILARITY_RELATED_TAG_THRESHOLD = 1000
|
||||||
METATAGS = "-user|user|-approver|approver|commenter|comm|noter|noteupdater|artcomm|-pool|pool|ordpool|-favgroup|favgroup|-fav|fav|ordfav|sub|md5|-rating|rating|-locked|locked|width|height|mpixels|ratio|score|favcount|filesize|source|-source|id|-id|date|age|order|limit|-status|status|tagcount|gentags|arttags|chartags|copytags|parent|-parent|child|pixiv_id|pixiv|search|upvote|downvote|filetype|-filetype"
|
METATAGS = "-user|user|-approver|approver|commenter|comm|noter|noteupdater|artcomm|-pool|pool|ordpool|-favgroup|favgroup|-fav|fav|ordfav|sub|md5|-rating|rating|-locked|locked|width|height|mpixels|ratio|score|favcount|filesize|source|-source|id|-id|date|age|order|limit|-status|status|tagcount|gentags|arttags|chartags|copytags|parent|-parent|child|pixiv_id|pixiv|search|upvote|downvote|filetype|-filetype"
|
||||||
SUBQUERY_METATAGS = "commenter|comm|noter|noteupdater|artcomm"
|
SUBQUERY_METATAGS = "commenter|comm|noter|noteupdater|artcomm"
|
||||||
attr_accessible :category, :as => [:moderator, :janitor, :gold, :platinum, :member, :anonymous, :default, :builder, :admin]
|
attr_accessible :category, :as => [:moderator, :gold, :platinum, :member, :anonymous, :default, :builder, :admin]
|
||||||
attr_accessible :is_locked, :as => [:moderator, :admin]
|
attr_accessible :is_locked, :as => [:moderator, :admin]
|
||||||
has_one :wiki_page, :foreign_key => "title", :primary_key => "name"
|
has_one :wiki_page, :foreign_key => "title", :primary_key => "name"
|
||||||
has_one :antecedent_alias, lambda {active}, :class_name => "TagAlias", :foreign_key => "antecedent_name", :primary_key => "name"
|
has_one :antecedent_alias, lambda {active}, :class_name => "TagAlias", :foreign_key => "antecedent_name", :primary_key => "name"
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ class User < ActiveRecord::Base
|
|||||||
GOLD = 30
|
GOLD = 30
|
||||||
PLATINUM = 31
|
PLATINUM = 31
|
||||||
BUILDER = 32
|
BUILDER = 32
|
||||||
JANITOR = 35
|
|
||||||
MODERATOR = 40
|
MODERATOR = 40
|
||||||
ADMIN = 50
|
ADMIN = 50
|
||||||
end
|
end
|
||||||
@@ -52,7 +51,7 @@ class User < ActiveRecord::Base
|
|||||||
has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs"
|
has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs"
|
||||||
|
|
||||||
attr_accessor :password, :old_password
|
attr_accessor :password, :old_password
|
||||||
attr_accessible :dmail_filter_attributes, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :disable_categorized_saved_searches, :disable_tagged_filenames, :enable_recent_searches, :as => [:moderator, :janitor, :gold, :platinum, :member, :anonymous, :default, :builder, :admin]
|
attr_accessible :dmail_filter_attributes, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :disable_categorized_saved_searches, :disable_tagged_filenames, :enable_recent_searches, :as => [:moderator, :gold, :platinum, :member, :anonymous, :default, :builder, :admin]
|
||||||
attr_accessible :level, :as => :admin
|
attr_accessible :level, :as => :admin
|
||||||
|
|
||||||
validates :name, user_name: true, on: :create
|
validates :name, user_name: true, on: :create
|
||||||
@@ -313,7 +312,6 @@ class User < ActiveRecord::Base
|
|||||||
"Gold" => Levels::GOLD,
|
"Gold" => Levels::GOLD,
|
||||||
"Platinum" => Levels::PLATINUM,
|
"Platinum" => Levels::PLATINUM,
|
||||||
"Builder" => Levels::BUILDER,
|
"Builder" => Levels::BUILDER,
|
||||||
"Janitor" => Levels::JANITOR,
|
|
||||||
"Moderator" => Levels::MODERATOR,
|
"Moderator" => Levels::MODERATOR,
|
||||||
"Admin" => Levels::ADMIN
|
"Admin" => Levels::ADMIN
|
||||||
}
|
}
|
||||||
@@ -336,9 +334,6 @@ class User < ActiveRecord::Base
|
|||||||
when Levels::PLATINUM
|
when Levels::PLATINUM
|
||||||
"Platinum"
|
"Platinum"
|
||||||
|
|
||||||
when Levels::JANITOR
|
|
||||||
"Janitor"
|
|
||||||
|
|
||||||
when Levels::MODERATOR
|
when Levels::MODERATOR
|
||||||
"Moderator"
|
"Moderator"
|
||||||
|
|
||||||
@@ -408,10 +403,6 @@ class User < ActiveRecord::Base
|
|||||||
level >= Levels::PLATINUM
|
level >= Levels::PLATINUM
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_janitor?
|
|
||||||
level >= Levels::JANITOR
|
|
||||||
end
|
|
||||||
|
|
||||||
def is_moderator?
|
def is_moderator?
|
||||||
level >= Levels::MODERATOR
|
level >= Levels::MODERATOR
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<%= render "listing", :post_versions => @post_versions %>
|
<%= render "listing", :post_versions => @post_versions %>
|
||||||
|
|
||||||
<% if params[:lr] && CurrentUser.is_janitor? %>
|
<% if params[:lr] && CurrentUser.is_moderator? %>
|
||||||
<p><%= link_to "Revert this user's changes", new_user_revert_path(:user_id => params[:lr]) %></p>
|
<p><%= link_to "Revert this user's changes", new_user_revert_path(:user_id => params[:lr]) %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<body>
|
|
||||||
<h1>Moderator Report For <%= Date.today %></h1>
|
|
||||||
|
|
||||||
<div style="margin-bottom: 2em;">
|
|
||||||
<table width="100%">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th width="15%" style="text-align: left;">Name</th>
|
|
||||||
<th width="10%" style="text-align: left;">Level</th>
|
|
||||||
<th width="10%" style="text-align: right;" title="Number of posts approved in past day">Appr 1</th>
|
|
||||||
<th width="10%" style="text-align: right;" title="Number of posts approved in past seven days">Appr 7</th>
|
|
||||||
<th width="10%" style="text-align: right;" title="Number of posts approved in past fourteen days">Appr 14</th>
|
|
||||||
<th width="10%" style="text-align: right;" title="Number of comments posted in past seven days">Comm</th>
|
|
||||||
<th width="35%" style="text-align: right;" title="Number of forum posts posted in past seven days">Forum</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<% User.find(:all, :conditions => ["level >= ?", CONFIG["user_levels"]["Test Janitor"]], :order => "level, name").each do |user| %>
|
|
||||||
<tr>
|
|
||||||
<td><%= link_to user.name, user_path(user, :host => Danbooru.config.hostname, :only_path => false) %></td>
|
|
||||||
<td><%= user.pretty_level %></td>
|
|
||||||
<td style="text-align: right;"><%= Post.count(:conditions => ["created_at >= ? AND approver_id = ?", 1.days.ago, user.id]) %>/<%= Post.count(:conditions => ["created_at >= ? AND (approver_id IS NOT NULL OR status = 'pending')", 1.days.ago]) %></td>
|
|
||||||
<td style="text-align: right;"><%= Post.count(:conditions => ["created_at >= ? AND approver_id = ?", 7.days.ago, user.id]) %>/<%= Post.count(:conditions => ["created_at >= ? AND (approver_id IS NOT NULL OR status = 'pending')", 7.days.ago]) %></td>
|
|
||||||
<td style="text-align: right;"><%= Post.count(:conditions => ["created_at >= ? AND approver_id = ?", 14.days.ago, user.id]) %>/<%= Post.count(:conditions => ["created_at >= ? AND (approver_id IS NOT NULL OR status = 'pending')", 14.days.ago]) %></td>
|
|
||||||
<td style="text-align: right;"><%= Comment.count(:conditions => ["created_at >= ? AND user_id = ?", 7.days.ago, user.id]) %></td>
|
|
||||||
<td style="text-align: right;"><%= ForumPost.count(:conditions => ["created_at >= ? AND creator_id = ?", 7.days.ago, user.id]) %></td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<% @super_voters.each do |super_voter| %>
|
<% @super_voters.each do |super_voter| %>
|
||||||
<li><%= link_to_if CurrentUser.user.is_janitor?, super_voter.user.name, posts_path(tags: "upvote:#{super_voter.user.name}") %></li>
|
<li><%= link_to_if CurrentUser.user.is_moderator?, super_voter.user.name, posts_path(tags: "upvote:#{super_voter.user.name}") %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -350,7 +350,6 @@ Users have a number attribute called level representing their role. The current
|
|||||||
* Gold: 30
|
* Gold: 30
|
||||||
* Platinum: 31
|
* Platinum: 31
|
||||||
* Builder: 32
|
* Builder: 32
|
||||||
* Janitor: 35
|
|
||||||
* Moderator: 40
|
* Moderator: 40
|
||||||
* Admin: 50
|
* Admin: 50
|
||||||
|
|
||||||
|
|||||||
@@ -43,12 +43,6 @@ FactoryGirl.define do
|
|||||||
bit_prefs User.flag_value_for("can_upload_free")
|
bit_prefs User.flag_value_for("can_upload_free")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
factory(:janitor_user) do
|
|
||||||
level 35
|
|
||||||
can_approve_posts true
|
|
||||||
end
|
|
||||||
|
|
||||||
factory(:moderator_user) do
|
factory(:moderator_user) do
|
||||||
level 40
|
level 40
|
||||||
can_approve_posts true
|
can_approve_posts true
|
||||||
|
|||||||
@@ -35,10 +35,6 @@ class BanTest < ActiveSupport::TestCase
|
|||||||
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
||||||
assert(ban.errors.empty?)
|
assert(ban.errors.empty?)
|
||||||
|
|
||||||
user = FactoryGirl.create(:janitor_user)
|
|
||||||
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
|
||||||
assert(ban.errors.empty?)
|
|
||||||
|
|
||||||
user = FactoryGirl.create(:contributor_user)
|
user = FactoryGirl.create(:contributor_user)
|
||||||
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
||||||
assert(ban.errors.empty?)
|
assert(ban.errors.empty?)
|
||||||
@@ -79,10 +75,6 @@ class BanTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "be valid against anyone who is not an admin or a moderator" do
|
should "be valid against anyone who is not an admin or a moderator" do
|
||||||
user = FactoryGirl.create(:janitor_user)
|
|
||||||
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
|
||||||
assert(ban.errors.empty?)
|
|
||||||
|
|
||||||
user = FactoryGirl.create(:contributor_user)
|
user = FactoryGirl.create(:contributor_user)
|
||||||
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
||||||
assert(ban.errors.empty?)
|
assert(ban.errors.empty?)
|
||||||
@@ -97,52 +89,6 @@ class BanTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "created by a janitor" do
|
|
||||||
setup do
|
|
||||||
@banner = FactoryGirl.create(:janitor_user)
|
|
||||||
CurrentUser.user = @banner
|
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
|
||||||
end
|
|
||||||
|
|
||||||
teardown do
|
|
||||||
@banner = nil
|
|
||||||
CurrentUser.user = nil
|
|
||||||
CurrentUser.ip_addr = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
should "always be invalid" do
|
|
||||||
user = FactoryGirl.create(:admin_user)
|
|
||||||
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
|
||||||
ban.save
|
|
||||||
assert(ban.errors.any?)
|
|
||||||
|
|
||||||
user = FactoryGirl.create(:moderator_user)
|
|
||||||
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
|
||||||
ban.save
|
|
||||||
assert(ban.errors.any?)
|
|
||||||
|
|
||||||
user = FactoryGirl.create(:janitor_user)
|
|
||||||
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
|
||||||
ban.save
|
|
||||||
assert(ban.errors.any?)
|
|
||||||
|
|
||||||
user = FactoryGirl.create(:contributor_user)
|
|
||||||
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
|
||||||
ban.save
|
|
||||||
assert(ban.errors.any?)
|
|
||||||
|
|
||||||
user = FactoryGirl.create(:gold_user)
|
|
||||||
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
|
||||||
ban.save
|
|
||||||
assert(ban.errors.any?)
|
|
||||||
|
|
||||||
user = FactoryGirl.create(:user)
|
|
||||||
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
|
||||||
ban.save
|
|
||||||
assert(ban.errors.any?)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
should "initialize the expiration date" do
|
should "initialize the expiration date" do
|
||||||
user = FactoryGirl.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
admin = FactoryGirl.create(:admin_user)
|
admin = FactoryGirl.create(:admin_user)
|
||||||
|
|||||||
@@ -420,8 +420,8 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "that was previously approved by person X" do
|
context "that was previously approved by person X" do
|
||||||
setup do
|
setup do
|
||||||
@user = FactoryGirl.create(:janitor_user, :name => "xxx")
|
@user = FactoryGirl.create(:moderator_user, :name => "xxx")
|
||||||
@user2 = FactoryGirl.create(:janitor_user, :name => "yyy")
|
@user2 = FactoryGirl.create(:moderator_user, :name => "yyy")
|
||||||
@post = FactoryGirl.create(:post, :approver_id => @user.id)
|
@post = FactoryGirl.create(:post, :approver_id => @user.id)
|
||||||
@post.flag!("bad")
|
@post.flag!("bad")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -63,12 +63,6 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
assert_equal(true, @user.can_upload_free)
|
assert_equal(true, @user.can_upload_free)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not allow invites up to janitor level or beyond" do
|
|
||||||
@user.invite!(User::Levels::JANITOR, "1")
|
|
||||||
@user.reload
|
|
||||||
assert_equal(User::Levels::MEMBER, @user.level)
|
|
||||||
end
|
|
||||||
|
|
||||||
should "create a mod action" do
|
should "create a mod action" do
|
||||||
assert_difference("ModAction.count") do
|
assert_difference("ModAction.count") do
|
||||||
@user.invite!(User::Levels::BUILDER, "1")
|
@user.invite!(User::Levels::BUILDER, "1")
|
||||||
@@ -152,31 +146,21 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
should "normalize its level" do
|
should "normalize its level" do
|
||||||
user = FactoryGirl.create(:user, :level => User::Levels::ADMIN)
|
user = FactoryGirl.create(:user, :level => User::Levels::ADMIN)
|
||||||
assert(user.is_moderator?)
|
assert(user.is_moderator?)
|
||||||
assert(user.is_janitor?)
|
|
||||||
assert(user.is_gold?)
|
assert(user.is_gold?)
|
||||||
|
|
||||||
user = FactoryGirl.create(:user, :level => User::Levels::MODERATOR)
|
user = FactoryGirl.create(:user, :level => User::Levels::MODERATOR)
|
||||||
assert(!user.is_admin?)
|
assert(!user.is_admin?)
|
||||||
assert(user.is_moderator?)
|
assert(user.is_moderator?)
|
||||||
assert(user.is_janitor?)
|
|
||||||
assert(user.is_gold?)
|
|
||||||
|
|
||||||
user = FactoryGirl.create(:user, :level => User::Levels::JANITOR)
|
|
||||||
assert(!user.is_admin?)
|
|
||||||
assert(!user.is_moderator?)
|
|
||||||
assert(user.is_janitor?)
|
|
||||||
assert(user.is_gold?)
|
assert(user.is_gold?)
|
||||||
|
|
||||||
user = FactoryGirl.create(:user, :level => User::Levels::GOLD)
|
user = FactoryGirl.create(:user, :level => User::Levels::GOLD)
|
||||||
assert(!user.is_admin?)
|
assert(!user.is_admin?)
|
||||||
assert(!user.is_moderator?)
|
assert(!user.is_moderator?)
|
||||||
assert(!user.is_janitor?)
|
|
||||||
assert(user.is_gold?)
|
assert(user.is_gold?)
|
||||||
|
|
||||||
user = FactoryGirl.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
assert(!user.is_admin?)
|
assert(!user.is_admin?)
|
||||||
assert(!user.is_moderator?)
|
assert(!user.is_moderator?)
|
||||||
assert(!user.is_janitor?)
|
|
||||||
assert(!user.is_gold?)
|
assert(!user.is_gold?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user