fixes #2469
This commit is contained in:
@@ -116,7 +116,7 @@ protected
|
||||
end
|
||||
end
|
||||
|
||||
%w(member banned builder gold platinum contributor janitor moderator admin).each do |level|
|
||||
%w(member banned builder gold platinum janitor moderator admin).each do |level|
|
||||
define_method("#{level}_only") do
|
||||
if !CurrentUser.user.is_banned? && CurrentUser.user.__send__("is_#{level}?")
|
||||
true
|
||||
|
||||
@@ -6,7 +6,7 @@ module Moderator
|
||||
end
|
||||
|
||||
def create
|
||||
User.find(params[:invitation][:user_id]).invite!(params[:invitation][:level])
|
||||
User.find(params[:invitation][:user_id]).invite!(params[:invitation][:level], params[:invitation][:can_upload_free])
|
||||
redirect_to moderator_invitations_path
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ module Admin::UsersHelper
|
||||
["Gold", User::Levels::GOLD],
|
||||
["Platinum", User::Levels::PLATINUM],
|
||||
["Builder", User::Levels::BUILDER],
|
||||
["Contributor", User::Levels::CONTRIBUTOR],
|
||||
["Janitor", User::Levels::JANITOR],
|
||||
["Moderator", User::Levels::MODERATOR],
|
||||
["Admin", User::Levels::ADMIN]
|
||||
|
||||
@@ -96,7 +96,7 @@ module ApplicationHelper
|
||||
html << " [" + link_to("+", new_user_feedback_path(:user_feedback => {:category => "positive", :user_id => user.id})) + "]"
|
||||
|
||||
unless user.is_gold?
|
||||
html << " [" + link_to("invite", new_moderator_invitation_path(:invitation => {:name => user.name, :level => User::Levels::CONTRIBUTOR})) + "]"
|
||||
html << " [" + link_to("invite", new_moderator_invitation_path(:invitation => {:name => user.name}, :flag => "can_upload_free")) + "]"
|
||||
end
|
||||
else
|
||||
html << " [" + link_to("–".html_safe, new_user_feedback_path(:user_feedback => {:category => "negative", :user_id => user.id})) + "]"
|
||||
|
||||
@@ -5,7 +5,7 @@ module Moderator
|
||||
["", ""],
|
||||
["Member", 20],
|
||||
["Gold", 30],
|
||||
["Contributor", 33],
|
||||
["Platinum", 31],
|
||||
["Janitor", 35],
|
||||
["Moderator", 40],
|
||||
["Admin", 50]
|
||||
|
||||
@@ -3,7 +3,7 @@ module Moderator
|
||||
def level_select
|
||||
choices = []
|
||||
choices << ["Gold", User::Levels::GOLD]
|
||||
choices << ["Contributor", User::Levels::CONTRIBUTOR]
|
||||
choices << ["Platinum", User::Levels::PLATINUM]
|
||||
select(:invitation, :level, choices)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -229,7 +229,11 @@ class AnonymousUser
|
||||
[]
|
||||
end
|
||||
|
||||
%w(member banned gold builder platinum contributor janitor moderator admin).each do |name|
|
||||
def can_upload_free?
|
||||
false
|
||||
end
|
||||
|
||||
%w(member banned gold builder platinum janitor moderator admin).each do |name|
|
||||
define_method("is_#{name}?") do
|
||||
false
|
||||
end
|
||||
|
||||
@@ -8,7 +8,6 @@ class DailyMaintenance
|
||||
Delayed::Job.delete_all(['created_at < ?', 7.days.ago])
|
||||
PostVote.delete_all(['created_at < ?', 1.month.ago])
|
||||
CommentVote.delete_all(['created_at < ?', 1.month.ago])
|
||||
# UserUploadClamper.new.clamp_all!
|
||||
TagSubscription.process_all
|
||||
ApiCacheGenerator.new.generate_tag_cache
|
||||
PostDisapproval.prune!
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'statistics2'
|
||||
module Reports
|
||||
class Contributors < User
|
||||
def users
|
||||
::User.where("users.level >= ? and users.post_upload_count >= 250", ::User::Levels::CONTRIBUTOR).order("created_at desc").map {|x| Reports::UserPromotions::User.new(x)}
|
||||
::User.where("users.bit_prefs & ? > 0 and users.post_upload_count >= 250", ::User.flag_value_for("can_upload_free")).order("created_at desc").map {|x| Reports::UserPromotions::User.new(x)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -66,7 +66,7 @@ module Reports
|
||||
end
|
||||
|
||||
def users
|
||||
::User.where("users.level < ? and users.post_upload_count >= 250", ::User::Levels::CONTRIBUTOR).order("created_at desc").map {|x| Reports::UserPromotions::User.new(x)}
|
||||
::User.where("users.bit_prefs & ? > 0 and users.post_upload_count >= 250", ::User.flag_value_for("can_upload_free")).order("created_at desc").map {|x| Reports::UserPromotions::User.new(x)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
class UserUploadClamper
|
||||
def clamp_all!
|
||||
users.each do |user|
|
||||
if clamp_user?(user)
|
||||
clamp_user!(user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def users
|
||||
User.where("post_upload_count >= 5000 and base_upload_limit is null and level <= ?", User::Levels::CONTRIBUTOR).limit(50)
|
||||
end
|
||||
|
||||
def clamp_user?(user)
|
||||
Reports::UserPromotions.deletion_confidence_interval_for(user) >= 7
|
||||
end
|
||||
|
||||
def clamp_user!(user)
|
||||
upload_limit = (Post.for_user(user).deleted.where("is_banned = false").count / 4) + 10
|
||||
user.update_attribute(:base_upload_limit, upload_limit)
|
||||
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
|
||||
user.promote_to!(User::Levels::BUILDER) if user.is_contributor?
|
||||
Dmail.create_split(:to_id => user.id, :title => "Post Upload Limit", :body => "You are receiving this message because a large percentage of your uploads are being deleted. For this reason you will now be limited to 10 uploads a day.")
|
||||
ModAction.create(:description => "user ##{user.id} (#{user.name}) clamped")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -14,8 +14,8 @@ class Artist < ActiveRecord::Base
|
||||
has_one :tag_alias, :foreign_key => "antecedent_name", :primary_key => "name"
|
||||
has_one :tag, :foreign_key => "name", :primary_key => "name"
|
||||
accepts_nested_attributes_for :wiki_page
|
||||
attr_accessible :body, :name, :url_string, :other_names, :other_names_comma, :group_name, :wiki_page_attributes, :notes, :as => [:member, :gold, :builder, :platinum, :contributor, :janitor, :moderator, :default, :admin]
|
||||
attr_accessible :is_active, :as => [:builder, :contributor, :janitor, :moderator, :default, :admin]
|
||||
attr_accessible :body, :name, :url_string, :other_names, :other_names_comma, :group_name, :wiki_page_attributes, :notes, :as => [:member, :gold, :builder, :platinum, :janitor, :moderator, :default, :admin]
|
||||
attr_accessible :is_active, :as => [:builder, :janitor, :moderator, :default, :admin]
|
||||
attr_accessible :is_banned, :as => :admin
|
||||
|
||||
module UrlMethods
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class DmailFilter < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
attr_accessible :user_id, :words, :as => [:moderator, :janitor, :contributor, :gold, :member, :anonymous, :default, :builder, :admin]
|
||||
attr_accessible :user_id, :words, :as => [:moderator, :janitor, :gold, :member, :anonymous, :default, :builder, :admin]
|
||||
validates_presence_of :user
|
||||
before_validation :initialize_user
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class FavoriteGroup < ActiveRecord::Base
|
||||
validate :creator_can_create_favorite_groups, :on => :create
|
||||
validate :validate_number_of_posts
|
||||
before_save :update_post_count
|
||||
attr_accessible :name, :post_ids, :post_id_array, :as => [:member, :gold, :platinum, :builder, :contributor, :janitor, :moderator, :admin, :default]
|
||||
attr_accessible :name, :post_ids, :post_id_array, :as => [:member, :gold, :platinum, :builder, :janitor, :moderator, :admin, :default]
|
||||
|
||||
module SearchMethods
|
||||
def for_creator(user_id)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class ForumPost < ActiveRecord::Base
|
||||
include Mentionable
|
||||
|
||||
attr_accessible :body, :topic_id, :as => [:member, :builder, :janitor, :gold, :platinum, :contributor, :admin, :moderator, :default]
|
||||
attr_accessible :body, :topic_id, :as => [:member, :builder, :janitor, :gold, :platinum, :admin, :moderator, :default]
|
||||
attr_accessible :is_locked, :is_sticky, :is_deleted, :as => [:admin, :moderator]
|
||||
attr_readonly :topic_id
|
||||
belongs_to :creator, :class_name => "User"
|
||||
|
||||
@@ -5,7 +5,7 @@ class ForumTopic < ActiveRecord::Base
|
||||
2 => "Bugs & Features"
|
||||
}
|
||||
|
||||
attr_accessible :title, :original_post_attributes, :category_id, :as => [:member, :builder, :gold, :platinum, :contributor, :janitor, :moderator, :admin, :default]
|
||||
attr_accessible :title, :original_post_attributes, :category_id, :as => [:member, :builder, :gold, :platinum, :janitor, :moderator, :admin, :default]
|
||||
attr_accessible :is_sticky, :is_locked, :is_deleted, :as => [:admin, :moderator]
|
||||
belongs_to :creator, :class_name => "User"
|
||||
belongs_to :updater, :class_name => "User"
|
||||
|
||||
@@ -27,7 +27,7 @@ class JanitorTrial < ActiveRecord::Base
|
||||
def self.message_candidates!
|
||||
admin = User.admins.first
|
||||
|
||||
User.where("last_logged_in_at >= ? and created_at <= ? and email is not null and (favorite_count >= 400 OR post_upload_count >= 400) and level between ? and ?", 1.week.ago, 6.months.ago, User::Levels::MEMBER, User::Levels::CONTRIBUTOR).order("random()").limit(10).each do |user|
|
||||
User.where("last_logged_in_at >= ? and created_at <= ? and email is not null and (favorite_count >= 400 OR post_upload_count >= 400) and bit_prefs & ? = 0", 1.week.ago, 6.months.ago, User.flag_value_for("can_approve_posts")).order("random()").limit(10).each do |user|
|
||||
if !Dmail.where("from_id = ? and to_id = ? and title = ?", admin.id, user.id, "Test Janitor Invitation").exists?
|
||||
favorites = user.favorites.order("random()").limit(400).map(&:post_id)
|
||||
uploads = user.posts.order("random()").limit(400).map(&:id)
|
||||
|
||||
@@ -18,7 +18,7 @@ class Pool < ActiveRecord::Base
|
||||
after_save :create_version
|
||||
after_create :synchronize!
|
||||
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, :contributor, :janitor, :moderator, :admin, :default]
|
||||
attr_accessible :name, :description, :post_ids, :post_id_array, :post_count, :is_active, :category, :as => [:member, :gold, :platinum, :janitor, :moderator, :admin, :default]
|
||||
attr_accessible :is_deleted, :as => [:moderator, :admin]
|
||||
|
||||
module SearchMethods
|
||||
|
||||
@@ -42,8 +42,8 @@ class Post < ActiveRecord::Base
|
||||
has_many :favorites, :dependent => :destroy
|
||||
validates_uniqueness_of :md5
|
||||
validate :post_is_not_its_own_parent
|
||||
attr_accessible :source, :rating, :tag_string, :old_tag_string, :old_parent_id, :old_source, :old_rating, :last_noted_at, :parent_id, :has_embedded_notes, :as => [:member, :builder, :gold, :platinum, :contributor, :janitor, :moderator, :admin, :default]
|
||||
attr_accessible :is_rating_locked, :is_note_locked, :as => [:builder, :contributor, :janitor, :moderator, :admin]
|
||||
attr_accessible :source, :rating, :tag_string, :old_tag_string, :old_parent_id, :old_source, :old_rating, :last_noted_at, :parent_id, :has_embedded_notes, :as => [:member, :builder, :gold, :platinum, :janitor, :moderator, :admin, :default]
|
||||
attr_accessible :is_rating_locked, :is_note_locked, :as => [:builder, :janitor, :moderator, :admin]
|
||||
attr_accessible :is_status_locked, :as => [:admin]
|
||||
|
||||
module FileMethods
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Tag < ActiveRecord::Base
|
||||
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"
|
||||
SUBQUERY_METATAGS = "commenter|comm|noter|noteupdater|artcomm"
|
||||
attr_accessible :category, :as => [:moderator, :janitor, :contributor, :gold, :member, :anonymous, :default, :builder, :admin]
|
||||
attr_accessible :category, :as => [:moderator, :janitor, :gold, :member, :anonymous, :default, :builder, :admin]
|
||||
attr_accessible :is_locked, :as => [:moderator, :admin]
|
||||
has_one :wiki_page, :foreign_key => "title", :primary_key => "name"
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ class Upload < ActiveRecord::Base
|
||||
p.uploader_ip_addr = uploader_ip_addr
|
||||
p.parent_id = parent_id
|
||||
|
||||
if !uploader.is_contributor? || upload_as_pending?
|
||||
if !uploader.can_upload_free? || upload_as_pending?
|
||||
p.is_pending = true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,6 @@ class User < ActiveRecord::Base
|
||||
GOLD = 30
|
||||
PLATINUM = 31
|
||||
BUILDER = 32
|
||||
CONTRIBUTOR = 33
|
||||
JANITOR = 35
|
||||
MODERATOR = 40
|
||||
ADMIN = 50
|
||||
@@ -32,13 +31,14 @@ class User < ActiveRecord::Base
|
||||
show_deleted_children
|
||||
has_saved_searches
|
||||
can_approve_posts
|
||||
can_upload_free
|
||||
)
|
||||
|
||||
include Danbooru::HasBitFlags
|
||||
has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs"
|
||||
|
||||
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, :as => [:moderator, :janitor, :contributor, :gold, :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, :as => [:moderator, :janitor, :gold, :member, :anonymous, :default, :builder, :admin]
|
||||
attr_accessible :level, :as => :admin
|
||||
validates_length_of :name, :within => 2..100, :on => :create
|
||||
validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"
|
||||
@@ -90,8 +90,14 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
module InvitationMethods
|
||||
def invite!(level)
|
||||
if level.to_i <= Levels::CONTRIBUTOR
|
||||
def invite!(level, can_upload_free)
|
||||
if can_upload_free
|
||||
self.can_upload_free = true
|
||||
else
|
||||
self.can_upload_free = false
|
||||
end
|
||||
|
||||
if level.to_i <= Levels::BUILDER
|
||||
self.level = level
|
||||
self.inviter_id = CurrentUser.id
|
||||
save
|
||||
@@ -274,7 +280,6 @@ class User < ActiveRecord::Base
|
||||
"Gold" => Levels::GOLD,
|
||||
"Platinum" => Levels::PLATINUM,
|
||||
"Builder" => Levels::BUILDER,
|
||||
"Contributor" => Levels::CONTRIBUTOR,
|
||||
"Janitor" => Levels::JANITOR,
|
||||
"Moderator" => Levels::MODERATOR,
|
||||
"Admin" => Levels::ADMIN
|
||||
@@ -307,9 +312,6 @@ class User < ActiveRecord::Base
|
||||
when Levels::BUILDER
|
||||
:builder
|
||||
|
||||
when Levels::CONTRIBUTOR
|
||||
:contributor
|
||||
|
||||
when Levels::MODERATOR
|
||||
:moderator
|
||||
|
||||
@@ -342,9 +344,6 @@ class User < ActiveRecord::Base
|
||||
when Levels::PLATINUM
|
||||
"Platinum"
|
||||
|
||||
when Levels::CONTRIBUTOR
|
||||
"Contributor"
|
||||
|
||||
when Levels::JANITOR
|
||||
"Janitor"
|
||||
|
||||
@@ -379,10 +378,6 @@ class User < ActiveRecord::Base
|
||||
level >= Levels::PLATINUM
|
||||
end
|
||||
|
||||
def is_contributor?
|
||||
level >= Levels::CONTRIBUTOR
|
||||
end
|
||||
|
||||
def is_janitor?
|
||||
level >= Levels::JANITOR
|
||||
end
|
||||
@@ -472,7 +467,7 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def can_upload?
|
||||
if is_contributor?
|
||||
if can_upload_free?
|
||||
true
|
||||
elsif created_at > 1.week.ago
|
||||
false
|
||||
|
||||
@@ -50,7 +50,7 @@ class UserPresenter
|
||||
end
|
||||
|
||||
def upload_limit
|
||||
if user.is_contributor?
|
||||
if user.can_upload_free?
|
||||
return "none"
|
||||
end
|
||||
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
<%= level_select %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<label>Unrestricted Uploads</label>
|
||||
<%= check_box :invitation, :can_upload_free %>
|
||||
</div>
|
||||
|
||||
<%= submit_tag %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
<div id="a-new">
|
||||
<h1>Upload</h1>
|
||||
|
||||
<% if CurrentUser.user.can_upload? %>
|
||||
<% if CurrentUser.can_upload? %>
|
||||
<div id="upload-guide-notice">
|
||||
<p>Before uploading, please read the <%= link_to "how to upload guide", wiki_pages_path(:title => "howto:upload") %>.</p>
|
||||
</div>
|
||||
|
||||
<% unless CurrentUser.is_contributor? %>
|
||||
<% unless CurrentUser.can_upload_free? %>
|
||||
<p>You can upload <strong><%= pluralize CurrentUser.upload_limit, "more post" %></strong> today.</p>
|
||||
<% end %>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<%= hidden_field_tag :normalized_url, @normalized_url %>
|
||||
<%= f.hidden_field :referer_url, :value => @source.try(:referer_url) %>
|
||||
|
||||
<% if CurrentUser.is_contributor? %>
|
||||
<% if CurrentUser.can_upload_free? %>
|
||||
<div class="input">
|
||||
<label for="upload_as_pending">
|
||||
<%= f.check_box :as_pending %>
|
||||
|
||||
@@ -350,7 +350,6 @@ Users have a number attribute called level representing their role. The current
|
||||
* Gold: 30
|
||||
* Platinum: 31
|
||||
* Builder: 32
|
||||
* Contributor: 33
|
||||
* Janitor: 35
|
||||
* Moderator: 40
|
||||
* Admin: 50
|
||||
|
||||
14
script/fixes/037_enable_can_upload_free.rb
Normal file
14
script/fixes/037_enable_can_upload_free.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
|
||||
|
||||
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
|
||||
|
||||
CurrentUser.user = User.admins.first
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
|
||||
User.where("level >= ?", User::Levels::CONTRIBUTOR).find_each do |user|
|
||||
user.can_upload_free = true
|
||||
user.level = User::Levels::BUILDER if user.level == User::Levels::CONTRIBUTOR
|
||||
user.save
|
||||
end
|
||||
@@ -29,7 +29,8 @@ FactoryGirl.define do
|
||||
end
|
||||
|
||||
factory(:contributor_user) do
|
||||
level 33
|
||||
level 32
|
||||
bit_prefs User.flag_value_for("can_upload_free")
|
||||
end
|
||||
|
||||
factory(:janitor_user) do
|
||||
|
||||
@@ -19,10 +19,11 @@ module Moderator
|
||||
end
|
||||
|
||||
should "create a new invite" do
|
||||
post :create, {:invitation => {:user_id => @user_1.id, :level => User::Levels::CONTRIBUTOR}}, {:user_id => @mod.id}
|
||||
post :create, {:invitation => {:user_id => @user_1.id, :level => User::Levels::BUILDER, :can_upload_free => "1"}}, {:user_id => @mod.id}
|
||||
assert_redirected_to(moderator_invitations_path)
|
||||
@user_1.reload
|
||||
assert_equal(User::Levels::CONTRIBUTOR, @user_1.level)
|
||||
assert_equal(User::Levels::BUILDER, @user_1.level)
|
||||
assert_equal(true, @user_1.can_upload_free?)
|
||||
end
|
||||
|
||||
should "list invites" do
|
||||
|
||||
@@ -59,22 +59,23 @@ class UserTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "work" do
|
||||
@user.invite!(User::Levels::CONTRIBUTOR)
|
||||
@user.invite!(User::Levels::BUILDER, "1")
|
||||
@user.reload
|
||||
assert_equal(User::Levels::CONTRIBUTOR, @user.level)
|
||||
assert_equal(User::Levels::BUILDER, @user.level)
|
||||
assert_equal(true, @user.can_upload_free)
|
||||
end
|
||||
|
||||
should "not allow invites up to janitor level or beyond" do
|
||||
@user.invite!(User::Levels::JANITOR)
|
||||
@user.invite!(User::Levels::JANITOR, "1")
|
||||
@user.reload
|
||||
assert_equal(User::Levels::MEMBER, @user.level)
|
||||
end
|
||||
|
||||
should "create a mod action" do
|
||||
assert_difference("ModAction.count") do
|
||||
@user.invite!(User::Levels::CONTRIBUTOR)
|
||||
@user.invite!(User::Levels::BUILDER, "1")
|
||||
end
|
||||
assert_equal(%{"#{@user.name}":/users/#{@user.id} level changed Member -> Contributor}, ModAction.last.description)
|
||||
assert_equal(%{"#{@user.name}":/users/#{@user.id} level changed Member -> Builder}, ModAction.last.description)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -88,10 +89,8 @@ class UserTest < ActiveSupport::TestCase
|
||||
|
||||
should "limit post uploads" do
|
||||
assert(!@user.can_upload?)
|
||||
@user.update_column(:level, User::Levels::CONTRIBUTOR)
|
||||
assert(@user.can_upload?)
|
||||
@user.update_column(:level, User::Levels::MEMBER)
|
||||
@user.update_column(:created_at, 15.days.ago)
|
||||
assert(@user.can_upload?)
|
||||
assert_equal(10, @user.upload_limit)
|
||||
|
||||
9.times do
|
||||
@@ -156,42 +155,30 @@ class UserTest < ActiveSupport::TestCase
|
||||
user = FactoryGirl.create(:user, :level => User::Levels::ADMIN)
|
||||
assert(user.is_moderator?)
|
||||
assert(user.is_janitor?)
|
||||
assert(user.is_contributor?)
|
||||
assert(user.is_gold?)
|
||||
|
||||
user = FactoryGirl.create(:user, :level => User::Levels::MODERATOR)
|
||||
assert(!user.is_admin?)
|
||||
assert(user.is_moderator?)
|
||||
assert(user.is_janitor?)
|
||||
assert(user.is_contributor?)
|
||||
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_contributor?)
|
||||
assert(user.is_gold?)
|
||||
|
||||
user = FactoryGirl.create(:user, :level => User::Levels::CONTRIBUTOR)
|
||||
assert(!user.is_admin?)
|
||||
assert(!user.is_moderator?)
|
||||
assert(!user.is_janitor?)
|
||||
assert(user.is_contributor?)
|
||||
assert(user.is_gold?)
|
||||
|
||||
user = FactoryGirl.create(:user, :level => User::Levels::GOLD)
|
||||
assert(!user.is_admin?)
|
||||
assert(!user.is_moderator?)
|
||||
assert(!user.is_janitor?)
|
||||
assert(!user.is_contributor?)
|
||||
assert(user.is_gold?)
|
||||
|
||||
user = FactoryGirl.create(:user)
|
||||
assert(!user.is_admin?)
|
||||
assert(!user.is_moderator?)
|
||||
assert(!user.is_janitor?)
|
||||
assert(!user.is_contributor?)
|
||||
assert(!user.is_gold?)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user