rename references of privileged to gold
This commit is contained in:
@@ -86,7 +86,7 @@ protected
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%w(member banned builder privileged platinum contributor janitor moderator admin).each do |level|
|
%w(member banned builder gold platinum contributor janitor moderator admin).each do |level|
|
||||||
define_method("#{level}_only") do
|
define_method("#{level}_only") do
|
||||||
if !CurrentUser.user.is_banned? && CurrentUser.user.__send__("is_#{level}?")
|
if !CurrentUser.user.is_banned? && CurrentUser.user.__send__("is_#{level}?")
|
||||||
true
|
true
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class PostVotesController < ApplicationController
|
class PostVotesController < ApplicationController
|
||||||
before_filter :privileged_only
|
before_filter :gold_only
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@post = Post.find(params[:post_id])
|
@post = Post.find(params[:post_id])
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class UserFeedbacksController < ApplicationController
|
class UserFeedbacksController < ApplicationController
|
||||||
before_filter :privileged_only, :only => [:new, :edit, :create, :update, :destroy]
|
before_filter :gold_only, :only => [:new, :edit, :create, :update, :destroy]
|
||||||
respond_to :html, :xml, :json
|
respond_to :html, :xml, :json
|
||||||
rescue_from User::PrivilegeError, :with => "static/access_denied"
|
rescue_from User::PrivilegeError, :with => "static/access_denied"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class UserNameChangeRequestsController < ApplicationController
|
class UserNameChangeRequestsController < ApplicationController
|
||||||
before_filter :privileged_only, :only => [:new, :create, :show]
|
before_filter :gold_only, :only => [:new, :create, :show]
|
||||||
before_filter :admin_only, :only => [:index, :approve, :reject, :destroy]
|
before_filter :admin_only, :only => [:index, :approve, :reject, :destroy]
|
||||||
rescue_from User::PrivilegeError, :with => :access_denied
|
rescue_from User::PrivilegeError, :with => :access_denied
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module Admin::UsersHelper
|
|||||||
def user_level_select(object, field)
|
def user_level_select(object, field)
|
||||||
options = [
|
options = [
|
||||||
["Member", User::Levels::MEMBER],
|
["Member", User::Levels::MEMBER],
|
||||||
["Gold", User::Levels::PRIVILEGED],
|
["Gold", User::Levels::GOLD],
|
||||||
["Platinum", User::Levels::PLATINUM],
|
["Platinum", User::Levels::PLATINUM],
|
||||||
["Builder", User::Levels::BUILDER],
|
["Builder", User::Levels::BUILDER],
|
||||||
["Contributor", User::Levels::CONTRIBUTOR],
|
["Contributor", User::Levels::CONTRIBUTOR],
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ module ApplicationHelper
|
|||||||
if positive_or_negative == :positive
|
if positive_or_negative == :positive
|
||||||
html << " [" + link_to("+", new_user_feedback_path(:user_feedback => {:category => "positive", :user_id => user.id})) + "]"
|
html << " [" + link_to("+", new_user_feedback_path(:user_feedback => {:category => "positive", :user_id => user.id})) + "]"
|
||||||
|
|
||||||
unless user.is_privileged?
|
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, :level => User::Levels::CONTRIBUTOR})) + "]"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module Moderator
|
|||||||
choices = [
|
choices = [
|
||||||
["", ""],
|
["", ""],
|
||||||
["Member", 20],
|
["Member", 20],
|
||||||
["Privileged", 30],
|
["Gold", 30],
|
||||||
["Contributor", 33],
|
["Contributor", 33],
|
||||||
["Janitor", 35],
|
["Janitor", 35],
|
||||||
["Moderator", 40],
|
["Moderator", 40],
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module Moderator
|
|||||||
module InvitationsHelper
|
module InvitationsHelper
|
||||||
def level_select
|
def level_select
|
||||||
choices = []
|
choices = []
|
||||||
choices << ["Privileged", User::Levels::PRIVILEGED]
|
choices << ["Gold", User::Levels::GOLD]
|
||||||
choices << ["Contributor", User::Levels::CONTRIBUTOR]
|
choices << ["Contributor", User::Levels::CONTRIBUTOR]
|
||||||
select(:invitation, :level, choices)
|
select(:invitation, :level, choices)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ class AnonymousUser
|
|||||||
""
|
""
|
||||||
end
|
end
|
||||||
|
|
||||||
%w(member banned privileged builder platinum contributor janitor moderator admin).each do |name|
|
%w(member banned gold builder platinum contributor janitor moderator admin).each do |name|
|
||||||
define_method("is_#{name}?") do
|
define_method("is_#{name}?") do
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ module PostSets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def has_deleted?
|
def has_deleted?
|
||||||
CurrentUser.is_privileged? && tag_string !~ /status/ && ::Post.tag_match("#{tag_string} status:deleted").exists?
|
CurrentUser.is_gold? && tag_string !~ /status/ && ::Post.tag_match("#{tag_string} status:deleted").exists?
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_explicit?
|
def has_explicit?
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ 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"
|
||||||
accepts_nested_attributes_for :wiki_page
|
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, :privileged, :builder, :platinum, :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, :contributor, :janitor, :moderator, :default, :admin]
|
||||||
attr_accessible :is_active, :as => [:builder, :contributor, :janitor, :moderator, :default, :admin]
|
attr_accessible :is_active, :as => [:builder, :contributor, :janitor, :moderator, :default, :admin]
|
||||||
attr_accessible :is_banned, :as => :admin
|
attr_accessible :is_banned, :as => :admin
|
||||||
|
|
||||||
@@ -116,8 +116,8 @@ class Artist < ActiveRecord::Base
|
|||||||
Artist.new.tap do |artist|
|
Artist.new.tap do |artist|
|
||||||
if params[:name]
|
if params[:name]
|
||||||
artist.name = params[:name]
|
artist.name = params[:name]
|
||||||
if CurrentUser.user.is_privileged?
|
if CurrentUser.user.is_gold?
|
||||||
# below privileged users are limited to two tags
|
# below gold users are limited to two tags
|
||||||
post = Post.tag_match("source:http #{artist.name} status:any").first
|
post = Post.tag_match("source:http #{artist.name} status:any").first
|
||||||
else
|
else
|
||||||
post = Post.tag_match("source:http #{artist.name}").first
|
post = Post.tag_match("source:http #{artist.name}").first
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class Favorite < ActiveRecord::Base
|
|||||||
return if Favorite.for_user(user.id).exists?(:user_id => user.id, :post_id => post.id)
|
return if Favorite.for_user(user.id).exists?(:user_id => user.id, :post_id => post.id)
|
||||||
Favorite.create(:user_id => user.id, :post_id => post.id)
|
Favorite.create(:user_id => user.id, :post_id => post.id)
|
||||||
Post.update_all("fav_count = fav_count + 1", "id = #{post.id}")
|
Post.update_all("fav_count = fav_count + 1", "id = #{post.id}")
|
||||||
Post.update_all("score = score + 1", "id = #{post.id}") if user.is_privileged?
|
Post.update_all("score = score + 1", "id = #{post.id}") if user.is_gold?
|
||||||
post.append_user_to_fav_string(user.id)
|
post.append_user_to_fav_string(user.id)
|
||||||
user.add_favorite!(post)
|
user.add_favorite!(post)
|
||||||
user.increment!(:favorite_count)
|
user.increment!(:favorite_count)
|
||||||
@@ -22,7 +22,7 @@ class Favorite < ActiveRecord::Base
|
|||||||
return unless Favorite.for_user(user.id).exists?(:user_id => user.id, :post_id => post.id)
|
return unless Favorite.for_user(user.id).exists?(:user_id => user.id, :post_id => post.id)
|
||||||
Favorite.destroy_all(:user_id => user.id, :post_id => post.id)
|
Favorite.destroy_all(:user_id => user.id, :post_id => post.id)
|
||||||
Post.update_all("fav_count = fav_count - 1", "id = #{post.id}")
|
Post.update_all("fav_count = fav_count - 1", "id = #{post.id}")
|
||||||
Post.update_all("score = score - 1", "id = #{post.id}") if user.is_privileged?
|
Post.update_all("score = score - 1", "id = #{post.id}") if user.is_gold?
|
||||||
post.delete_user_from_fav_string(user.id)
|
post.delete_user_from_fav_string(user.id)
|
||||||
user.remove_favorite!(post)
|
user.remove_favorite!(post)
|
||||||
user.decrement!(:favorite_count)
|
user.decrement!(:favorite_count)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class ForumPost < ActiveRecord::Base
|
class ForumPost < ActiveRecord::Base
|
||||||
attr_accessible :body, :topic_id, :as => [:member, :builder, :janitor, :privileged, :platinum, :contributor, :admin, :moderator, :default]
|
attr_accessible :body, :topic_id, :as => [:member, :builder, :janitor, :gold, :platinum, :contributor, :admin, :moderator, :default]
|
||||||
attr_accessible :is_locked, :is_sticky, :is_deleted, :as => [:admin, :moderator, :janitor]
|
attr_accessible :is_locked, :is_sticky, :is_deleted, :as => [:admin, :moderator, :janitor]
|
||||||
belongs_to :creator, :class_name => "User"
|
belongs_to :creator, :class_name => "User"
|
||||||
belongs_to :updater, :class_name => "User"
|
belongs_to :updater, :class_name => "User"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class ForumTopic < ActiveRecord::Base
|
class ForumTopic < ActiveRecord::Base
|
||||||
attr_accessible :title, :original_post_attributes, :as => [:member, :builder, :privileged, :platinum, :contributor, :janitor, :moderator, :admin, :default]
|
attr_accessible :title, :original_post_attributes, :as => [:member, :builder, :gold, :platinum, :contributor, :janitor, :moderator, :admin, :default]
|
||||||
attr_accessible :is_sticky, :is_locked, :is_deleted, :as => [:janitor, :admin, :moderator]
|
attr_accessible :is_sticky, :is_locked, :is_deleted, :as => [:janitor, :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"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class Pool < ActiveRecord::Base
|
|||||||
before_validation :initialize_creator, :on => :create
|
before_validation :initialize_creator, :on => :create
|
||||||
after_save :create_version
|
after_save :create_version
|
||||||
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, :as => [:member, :privileged, :platinum, :contributor, :janitor, :moderator, :admin, :default]
|
attr_accessible :name, :description, :post_ids, :post_id_array, :post_count, :is_active, :as => [:member, :gold, :platinum, :contributor, :janitor, :moderator, :admin, :default]
|
||||||
attr_accessible :is_deleted, :as => [:janitor, :moderator, :admin]
|
attr_accessible :is_deleted, :as => [:janitor, :moderator, :admin]
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class Post < ActiveRecord::Base
|
|||||||
has_many :disapprovals, :class_name => "PostDisapproval", :dependent => :destroy
|
has_many :disapprovals, :class_name => "PostDisapproval", :dependent => :destroy
|
||||||
validates_uniqueness_of :md5
|
validates_uniqueness_of :md5
|
||||||
validates_presence_of :parent, :if => lambda {|rec| !rec.parent_id.nil?}
|
validates_presence_of :parent, :if => lambda {|rec| !rec.parent_id.nil?}
|
||||||
attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at, :parent_id, :as => [:member, :builder, :privileged, :platinum, :contributor, :janitor, :moderator, :admin, :default]
|
attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at, :parent_id, :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 :is_rating_locked, :is_note_locked, :as => [:builder, :contributor, :janitor, :moderator, :admin]
|
||||||
attr_accessible :is_status_locked, :as => [:admin]
|
attr_accessible :is_status_locked, :as => [:admin]
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ class TagSubscription < ActiveRecord::Base
|
|||||||
def self.process_all
|
def self.process_all
|
||||||
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
|
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
|
||||||
find_each do |tag_subscription|
|
find_each do |tag_subscription|
|
||||||
if $job_task_daemon_active != false && tag_subscription.creator.is_privileged? && tag_subscription.is_active?
|
if $job_task_daemon_active != false && tag_subscription.creator.is_gold? && tag_subscription.is_active?
|
||||||
begin
|
begin
|
||||||
tag_subscription.process
|
tag_subscription.process
|
||||||
tag_subscription.save
|
tag_subscription.save
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class User < ActiveRecord::Base
|
|||||||
module Levels
|
module Levels
|
||||||
BLOCKED = 10
|
BLOCKED = 10
|
||||||
MEMBER = 20
|
MEMBER = 20
|
||||||
PRIVILEGED = 30
|
GOLD = 30
|
||||||
PLATINUM = 31
|
PLATINUM = 31
|
||||||
BUILDER = 32
|
BUILDER = 32
|
||||||
CONTRIBUTOR = 33
|
CONTRIBUTOR = 33
|
||||||
@@ -17,7 +17,7 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :password, :old_password
|
attr_accessor :password, :old_password
|
||||||
attr_accessible :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, :as => [:moderator, :janitor, :contributor, :privileged, :member, :anonymous, :default, :builder, :admin]
|
attr_accessible :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, :as => [:moderator, :janitor, :contributor, :gold, :member, :anonymous, :default, :builder, :admin]
|
||||||
attr_accessible :level, :as => :admin
|
attr_accessible :level, :as => :admin
|
||||||
validates_length_of :name, :within => 2..100, :on => :create
|
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"
|
validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"
|
||||||
@@ -229,7 +229,7 @@ class User < ActiveRecord::Base
|
|||||||
def level_hash
|
def level_hash
|
||||||
return {
|
return {
|
||||||
"Member" => Levels::MEMBER,
|
"Member" => Levels::MEMBER,
|
||||||
"Gold" => Levels::PRIVILEGED,
|
"Gold" => Levels::GOLD,
|
||||||
"Platinum" => Levels::PLATINUM,
|
"Platinum" => Levels::PLATINUM,
|
||||||
"Builder" => Levels::BUILDER,
|
"Builder" => Levels::BUILDER,
|
||||||
"Contributor" => Levels::CONTRIBUTOR,
|
"Contributor" => Levels::CONTRIBUTOR,
|
||||||
@@ -255,8 +255,8 @@ class User < ActiveRecord::Base
|
|||||||
when Levels::MEMBER
|
when Levels::MEMBER
|
||||||
:member
|
:member
|
||||||
|
|
||||||
when Levels::PRIVILEGED
|
when Levels::GOLD
|
||||||
:privileged
|
:gold
|
||||||
|
|
||||||
when Levels::BUILDER
|
when Levels::BUILDER
|
||||||
:builder
|
:builder
|
||||||
@@ -286,7 +286,7 @@ class User < ActiveRecord::Base
|
|||||||
when Levels::BUILDER
|
when Levels::BUILDER
|
||||||
"Builder"
|
"Builder"
|
||||||
|
|
||||||
when Levels::PRIVILEGED
|
when Levels::GOLD
|
||||||
"Gold"
|
"Gold"
|
||||||
|
|
||||||
when Levels::PLATINUM
|
when Levels::PLATINUM
|
||||||
@@ -321,8 +321,8 @@ class User < ActiveRecord::Base
|
|||||||
level >= Levels::BUILDER
|
level >= Levels::BUILDER
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_privileged?
|
def is_gold?
|
||||||
level >= Levels::PRIVILEGED
|
level >= Levels::GOLD
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_platinum?
|
def is_platinum?
|
||||||
@@ -356,7 +356,7 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_per_page
|
def set_per_page
|
||||||
if per_page.nil? || !is_privileged?
|
if per_page.nil? || !is_gold?
|
||||||
self.per_page = Danbooru.config.posts_per_page
|
self.per_page = Danbooru.config.posts_per_page
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -398,7 +398,7 @@ class User < ActiveRecord::Base
|
|||||||
|
|
||||||
module ForumMethods
|
module ForumMethods
|
||||||
def has_forum_been_updated?
|
def has_forum_been_updated?
|
||||||
return false unless is_privileged?
|
return false unless is_gold?
|
||||||
newest_topic = ForumTopic.order("updated_at desc").first
|
newest_topic = ForumTopic.order("updated_at desc").first
|
||||||
return false if newest_topic.nil?
|
return false if newest_topic.nil?
|
||||||
return true if last_forum_read_at.nil?
|
return true if last_forum_read_at.nil?
|
||||||
@@ -426,7 +426,7 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def can_comment?
|
def can_comment?
|
||||||
if is_privileged?
|
if is_gold?
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
created_at <= Danbooru.config.member_comment_time_threshold
|
created_at <= Danbooru.config.member_comment_time_threshold
|
||||||
@@ -434,7 +434,7 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def is_comment_limited?
|
def is_comment_limited?
|
||||||
if is_privileged?
|
if is_gold?
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
Comment.where("creator_id = ? and created_at > ?", id, 1.hour.ago).count >= Danbooru.config.member_comment_limit
|
Comment.where("creator_id = ? and created_at > ?", id, 1.hour.ago).count >= Danbooru.config.member_comment_limit
|
||||||
@@ -470,7 +470,7 @@ class User < ActiveRecord::Base
|
|||||||
def tag_query_limit
|
def tag_query_limit
|
||||||
if is_platinum?
|
if is_platinum?
|
||||||
Danbooru.config.base_tag_query_limit * 2
|
Danbooru.config.base_tag_query_limit * 2
|
||||||
elsif is_privileged?
|
elsif is_gold?
|
||||||
Danbooru.config.base_tag_query_limit
|
Danbooru.config.base_tag_query_limit
|
||||||
else
|
else
|
||||||
2
|
2
|
||||||
@@ -480,7 +480,7 @@ class User < ActiveRecord::Base
|
|||||||
def favorite_limit
|
def favorite_limit
|
||||||
if is_platinum?
|
if is_platinum?
|
||||||
nil
|
nil
|
||||||
elsif is_privileged?
|
elsif is_gold?
|
||||||
20_000
|
20_000
|
||||||
else
|
else
|
||||||
10_000
|
10_000
|
||||||
@@ -490,7 +490,7 @@ class User < ActiveRecord::Base
|
|||||||
def api_hourly_limit
|
def api_hourly_limit
|
||||||
if is_platinum?
|
if is_platinum?
|
||||||
20_000
|
20_000
|
||||||
elsif is_privileged?
|
elsif is_gold?
|
||||||
10_000
|
10_000
|
||||||
else
|
else
|
||||||
3_000
|
3_000
|
||||||
@@ -500,7 +500,7 @@ class User < ActiveRecord::Base
|
|||||||
def statement_timeout
|
def statement_timeout
|
||||||
if is_platinum?
|
if is_platinum?
|
||||||
9_000
|
9_000
|
||||||
elsif is_privileged?
|
elsif is_gold?
|
||||||
6_000
|
6_000
|
||||||
else
|
else
|
||||||
3_000
|
3_000
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class UserFeedback < ActiveRecord::Base
|
|||||||
before_validation :initialize_creator, :on => :create
|
before_validation :initialize_creator, :on => :create
|
||||||
attr_accessible :body, :user_id, :category, :user_name
|
attr_accessible :body, :user_id, :category, :user_name
|
||||||
validates_presence_of :user, :creator, :body, :category
|
validates_presence_of :user, :creator, :body, :category
|
||||||
validate :creator_is_privileged
|
validate :creator_is_gold
|
||||||
validate :user_is_not_creator
|
validate :user_is_not_creator
|
||||||
after_create :create_dmail
|
after_create :create_dmail
|
||||||
|
|
||||||
@@ -73,9 +73,9 @@ class UserFeedback < ActiveRecord::Base
|
|||||||
Dmail.create_split(:to_id => user_id, :title => "Your user record has been updated", :body => body)
|
Dmail.create_split(:to_id => user_id, :title => "Your user record has been updated", :body => body)
|
||||||
end
|
end
|
||||||
|
|
||||||
def creator_is_privileged
|
def creator_is_gold
|
||||||
if !creator.is_privileged?
|
if !creator.is_gold?
|
||||||
errors[:creator] << "must be privileged"
|
errors[:creator] << "must be gold"
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class PostPresenter < Presenter
|
|||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
if post.is_banned? && !CurrentUser.is_privileged?
|
if post.is_banned? && !CurrentUser.is_gold?
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -113,8 +113,8 @@ class PostPresenter < Presenter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def image_html(template)
|
def image_html(template)
|
||||||
return template.content_tag("p", "The artist requested removal of this image") if @post.is_banned? && !CurrentUser.user.is_privileged?
|
return template.content_tag("p", "The artist requested removal of this image") if @post.is_banned? && !CurrentUser.user.is_gold?
|
||||||
return template.content_tag("p", template.link_to("You need a privileged account to see this image.", template.upgrade_information_users_path)) if !Danbooru.config.can_user_see_post?(CurrentUser.user, @post)
|
return template.content_tag("p", template.link_to("You need a gold account to see this image.", template.upgrade_information_users_path)) if !Danbooru.config.can_user_see_post?(CurrentUser.user, @post)
|
||||||
|
|
||||||
if @post.is_flash?
|
if @post.is_flash?
|
||||||
template.render("posts/partials/show/flash", :post => @post)
|
template.render("posts/partials/show/flash", :post => @post)
|
||||||
@@ -127,12 +127,12 @@ class PostPresenter < Presenter
|
|||||||
|
|
||||||
def tag_list_html(template, options = {})
|
def tag_list_html(template, options = {})
|
||||||
@tag_set_presenter ||= TagSetPresenter.new(@post.tag_array)
|
@tag_set_presenter ||= TagSetPresenter.new(@post.tag_array)
|
||||||
@tag_set_presenter.tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_privileged?))
|
@tag_set_presenter.tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_gold?))
|
||||||
end
|
end
|
||||||
|
|
||||||
def split_tag_list_html(template, options = {})
|
def split_tag_list_html(template, options = {})
|
||||||
@tag_set_presenter ||= TagSetPresenter.new(@post.tag_array)
|
@tag_set_presenter ||= TagSetPresenter.new(@post.tag_array)
|
||||||
@tag_set_presenter.split_tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_privileged?))
|
@tag_set_presenter.split_tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_gold?))
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_nav_links?(template)
|
def has_nav_links?(template)
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ private
|
|||||||
html << %{<a class="wiki-link" href="/wiki_pages/show_or_new?title=#{u(tag)}">?</a> }
|
html << %{<a class="wiki-link" href="/wiki_pages/show_or_new?title=#{u(tag)}">?</a> }
|
||||||
end
|
end
|
||||||
|
|
||||||
if CurrentUser.user.is_privileged? && is_index?(template) && current_query.present?
|
if CurrentUser.user.is_gold? && is_index?(template) && current_query.present?
|
||||||
html << %{<a href="/posts?tags=#{u(current_query)}+#{u(tag)}" class="search-inc-tag">+</a> }
|
html << %{<a href="/posts?tags=#{u(current_query)}+#{u(tag)}" class="search-inc-tag">+</a> }
|
||||||
html << %{<a href="/posts?tags=#{u(current_query)}+-#{u(tag)}" class="search-exl-tag">–</a> }
|
html << %{<a href="/posts?tags=#{u(current_query)}+-#{u(tag)}" class="search-exl-tag">–</a> }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<strong>Score</strong>
|
<strong>Score</strong>
|
||||||
<span>
|
<span>
|
||||||
<span id="score-for-post-<%= post.id %>"><%= post.score %></span>
|
<span id="score-for-post-<%= post.id %>"><%= post.score %></span>
|
||||||
<% if CurrentUser.is_privileged? %>
|
<% if CurrentUser.is_gold? %>
|
||||||
(vote <%= link_to("up", post_votes_path(:score => "up", :post_id => post.id), :remote => true, :method => :post) %>/<%= link_to("down", post_votes_path(:score => "down", :post_id => post.id), :remote => true, :method => :post) %>)
|
(vote <%= link_to("up", post_votes_path(:score => "up", :post_id => post.id), :remote => true, :method => :post) %>/<%= link_to("down", post_votes_path(:score => "down", :post_id => post.id), :remote => true, :method => :post) %>)
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<aside id="sidebar">
|
<aside id="sidebar">
|
||||||
<%= render "posts/partials/common/search", :path => favorites_path, :tags => @favorite_set.tag_string %>
|
<%= render "posts/partials/common/search", :path => favorites_path, :tags => @favorite_set.tag_string %>
|
||||||
|
|
||||||
<% if CurrentUser.is_privileged? %>
|
<% if CurrentUser.is_gold? %>
|
||||||
<section id="mode-box">
|
<section id="mode-box">
|
||||||
<%= render "posts/partials/index/mode_menu" %>
|
<%= render "posts/partials/index/mode_menu" %>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
<%= render "users/sign_up_notice" %>
|
<%= render "users/sign_up_notice" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if !CurrentUser.is_anonymous? && !CurrentUser.is_privileged? && cookies[:hide_upgrade_account_notice].blank? && params[:action] != "upgrade_information" %>
|
<% if !CurrentUser.is_anonymous? && !CurrentUser.is_gold? && cookies[:hide_upgrade_account_notice].blank? && params[:action] != "upgrade_information" %>
|
||||||
<%= render "users/upgrade_notice" %>
|
<%= render "users/upgrade_notice" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
<%= render "users/dmail_notice" %>
|
<%= render "users/dmail_notice" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if cookies["accepted_tos"].blank? && !CurrentUser.is_privileged? %>
|
<% if cookies["accepted_tos"].blank? && !CurrentUser.is_gold? %>
|
||||||
<%= render "users/tos" %>
|
<%= render "users/tos" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<% if CurrentUser.is_privileged? %>
|
<% if CurrentUser.is_gold? %>
|
||||||
<section id="mode-box">
|
<section id="mode-box">
|
||||||
<h1>Mode</h1>
|
<h1>Mode</h1>
|
||||||
<form action="/">
|
<form action="/">
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>Source: <%= post_source_tag(post) %></li>
|
<li>Source: <%= post_source_tag(post) %></li>
|
||||||
<li>Rating: <%= post.pretty_rating %></li>
|
<li>Rating: <%= post.pretty_rating %></li>
|
||||||
<li>Score: <span id="score-for-post-<%= post.id %>"><%= post.score %></span> <% if CurrentUser.is_privileged? %>(vote <%= link_to "up", post_votes_path(:post_id => post.id, :score => "up"), :remote => true, :method => :post %>/<%= link_to "down", post_votes_path(:post_id => post.id, :score => "down"), :remote => true, :method => :post %>)<% end %></li>
|
<li>Score: <span id="score-for-post-<%= post.id %>"><%= post.score %></span> <% if CurrentUser.is_gold? %>(vote <%= link_to "up", post_votes_path(:post_id => post.id, :score => "up"), :remote => true, :method => :post %>/<%= link_to "down", post_votes_path(:post_id => post.id, :score => "down"), :remote => true, :method => :post %>)<% end %></li>
|
||||||
<li>Favorites: <span id="favcount-for-post-<%= post.id %>"><%= post.fav_count %></span>
|
<li>Favorites: <span id="favcount-for-post-<%= post.id %>"><%= post.fav_count %></span>
|
||||||
<% if CurrentUser.is_privileged? && post.fav_count > 0 %>
|
<% if CurrentUser.is_gold? && post.fav_count > 0 %>
|
||||||
<%= link_to "»".html_safe, favorites_path(:post_id => post.id), :remote => true, :id => "show-favlist-link" %>
|
<%= link_to "»".html_safe, favorites_path(:post_id => post.id), :remote => true, :id => "show-favlist-link" %>
|
||||||
<%= link_to "«".html_safe, "#", :id => "hide-favlist-link" %>
|
<%= link_to "«".html_safe, "#", :id => "hide-favlist-link" %>
|
||||||
<div id="favlist"></div>
|
<div id="favlist"></div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<% content_for(:secondary_links) do %>
|
<% content_for(:secondary_links) do %>
|
||||||
<menu>
|
<menu>
|
||||||
<% if CurrentUser.is_privileged? %>
|
<% if CurrentUser.is_gold? %>
|
||||||
<% if @user_feedback %>
|
<% if @user_feedback %>
|
||||||
<li><%= link_to "New", new_user_feedback_path(:user_feedback => {:user_id => @user_feedback.user_id}) %></li>
|
<li><%= link_to "New", new_user_feedback_path(:user_feedback => {:user_id => @user_feedback.user_id}) %></li>
|
||||||
<% elsif params[:search] && params[:search][:user_id] %>
|
<% elsif params[:search] && params[:search][:user_id] %>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<li>|</li>
|
<li>|</li>
|
||||||
<% if @user.id == CurrentUser.id %>
|
<% if @user.id == CurrentUser.id %>
|
||||||
<li><%= link_to "Settings", edit_user_path(CurrentUser.user) %></li>
|
<li><%= link_to "Settings", edit_user_path(CurrentUser.user) %></li>
|
||||||
<% if @user.is_privileged? %>
|
<% if @user.is_gold? %>
|
||||||
<li><%= link_to "Edit subscriptions", tag_subscriptions_path %></li>
|
<li><%= link_to "Edit subscriptions", tag_subscriptions_path %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li><%= link_to "Profile", user_path(CurrentUser.user) %></li>
|
<li><%= link_to "Profile", user_path(CurrentUser.user) %></li>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
<li><%= link_to "Send message", new_dmail_path(:dmail => {:to_id => @user.id}) %></li>
|
<li><%= link_to "Send message", new_dmail_path(:dmail => {:to_id => @user.id}) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if !CurrentUser.is_privileged? %>
|
<% if !CurrentUser.is_gold? %>
|
||||||
<li><%= link_to "Upgrade", upgrade_information_users_path %></li>
|
<li><%= link_to "Upgrade", upgrade_information_users_path %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<div class="input">
|
<div class="input">
|
||||||
<label>Name</label>
|
<label>Name</label>
|
||||||
|
|
||||||
<% if CurrentUser.user.is_privileged? %>
|
<% if CurrentUser.user.is_gold? %>
|
||||||
<p><%= link_to "Request a name change", new_user_name_change_request_path %></p>
|
<p><%= link_to "Request a name change", new_user_name_change_request_path %></p>
|
||||||
<% else %>
|
<% else %>
|
||||||
<p>You must <%= link_to "upgrade your account", upgrade_information_users_path %> to request a name change</p>
|
<p>You must <%= link_to "upgrade your account", upgrade_information_users_path %> to request a name change</p>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
<%= f.input :comment_threshold, :hint => "Comments below this score will be hidden by default" %>
|
<%= f.input :comment_threshold, :hint => "Comments below this score will be hidden by default" %>
|
||||||
<%= f.input :default_image_size, :hint => "Show original image or show resampled #{Danbooru.config.large_image_width} pixel version", :label => "Default image width", :collection => [["850px", "large"], ["original", "original"]], :include_blank => false %>
|
<%= f.input :default_image_size, :hint => "Show original image or show resampled #{Danbooru.config.large_image_width} pixel version", :label => "Default image width", :collection => [["850px", "large"], ["original", "original"]], :include_blank => false %>
|
||||||
|
|
||||||
<% if CurrentUser.user.is_privileged? %>
|
<% if CurrentUser.user.is_gold? %>
|
||||||
<%= f.input :per_page, :label => "Posts per page", :as => :select, :collection => (1..100), :include_blank => false %>
|
<%= f.input :per_page, :label => "Posts per page", :as => :select, :collection => (1..100), :include_blank => false %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ module Danbooru
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set to true to give all new users privileged access.
|
# Set to true to give all new users gold access.
|
||||||
def start_as_privileged?
|
def start_as_gold?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ module Danbooru
|
|||||||
|
|
||||||
# Determines who can see ads.
|
# Determines who can see ads.
|
||||||
def can_see_ads?(user)
|
def can_see_ads?(user)
|
||||||
!user.is_privileged?
|
!user.is_gold?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Users cannot search for more than X regular tags at a time.
|
# Users cannot search for more than X regular tags at a time.
|
||||||
@@ -231,7 +231,7 @@ module Danbooru
|
|||||||
end
|
end
|
||||||
|
|
||||||
def is_user_restricted?(user)
|
def is_user_restricted?(user)
|
||||||
!user.is_privileged?
|
!user.is_gold?
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_user_advertiser?(user)
|
def is_user_advertiser?(user)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div style="text-align: center; margin-top: 5em;">
|
<div style="text-align: center; margin-top: 5em;">
|
||||||
<p style="width: 40em; margin: auto;">The server is currently overloaded. You can purchase a <a href="/503-redirect.html">privileged account</a> for $20 to view this page anyway.</p>
|
<p style="width: 40em; margin: auto;">The server is currently overloaded. You can purchase a <a href="/503-redirect.html">gold account</a> for $20 to view this page anyway.</p>
|
||||||
<p style="width: 40em; margin: auto;"> This page will automatically refresh in one minute.</p>
|
<p style="width: 40em; margin: auto;"> This page will automatically refresh in one minute.</p>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ FactoryGirl.define do
|
|||||||
ban {|x| x.association(:ban)}
|
ban {|x| x.association(:ban)}
|
||||||
end
|
end
|
||||||
|
|
||||||
factory(:privileged_user) do
|
factory(:gold_user) do
|
||||||
level 30
|
level 30
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class PostVotesControllerTest < ActionController::TestCase
|
class PostVotesControllerTest < ActionController::TestCase
|
||||||
context "The post vote controller" do
|
context "The post vote controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = FactoryGirl.create(:privileged_user)
|
@user = FactoryGirl.create(:gold_user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@post = FactoryGirl.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class UserFeedbacksControllerTest < ActionController::TestCase
|
|||||||
context "The user feedbacks controller" do
|
context "The user feedbacks controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = FactoryGirl.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@critic = FactoryGirl.create(:privileged_user)
|
@critic = FactoryGirl.create(:gold_user)
|
||||||
CurrentUser.user = @critic
|
CurrentUser.user = @critic
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class UserNameChangeRequestsControllerTest < ActionController::TestCase
|
class UserNameChangeRequestsControllerTest < ActionController::TestCase
|
||||||
context "The user name change requests controller" do
|
context "The user name change requests controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = FactoryGirl.create(:privileged_user)
|
@user = FactoryGirl.create(:gold_user)
|
||||||
@admin = FactoryGirl.create(:admin_user)
|
@admin = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ 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(:privileged_user)
|
user = FactoryGirl.create(:gold_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?)
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ 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(:privileged_user)
|
user = FactoryGirl.create(:gold_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?)
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ class BanTest < ActiveSupport::TestCase
|
|||||||
ban.save
|
ban.save
|
||||||
assert(ban.errors.any?)
|
assert(ban.errors.any?)
|
||||||
|
|
||||||
user = FactoryGirl.create(:privileged_user)
|
user = FactoryGirl.create(:gold_user)
|
||||||
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
||||||
ban.save
|
ban.save
|
||||||
assert(ban.errors.any?)
|
assert(ban.errors.any?)
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ module PostSets
|
|||||||
@set = PostSets::Post.new("a b c")
|
@set = PostSets::Post.new("a b c")
|
||||||
end
|
end
|
||||||
|
|
||||||
context "for a non-privileged user" do
|
context "for a non-gold user" do
|
||||||
should "fail" do
|
should "fail" do
|
||||||
assert_raises(::Post::SearchError) do
|
assert_raises(::Post::SearchError) do
|
||||||
@set.posts
|
@set.posts
|
||||||
@@ -106,9 +106,9 @@ module PostSets
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "for a privileged user" do
|
context "for a gold user" do
|
||||||
setup do
|
setup do
|
||||||
CurrentUser.user = FactoryGirl.create(:privileged_user)
|
CurrentUser.user = FactoryGirl.create(:gold_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "pass" do
|
should "pass" do
|
||||||
|
|||||||
@@ -704,7 +704,7 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "decrement the post's score for privileged users" do
|
should "decrement the post's score for gold users" do
|
||||||
@post.remove_favorite!(@user)
|
@post.remove_favorite!(@user)
|
||||||
@post.reload
|
@post.reload
|
||||||
assert_equal(0, @post.score)
|
assert_equal(0, @post.score)
|
||||||
@@ -757,7 +757,7 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "increment the post's score for privileged users" do
|
should "increment the post's score for gold users" do
|
||||||
@post.add_favorite!(@user)
|
@post.add_favorite!(@user)
|
||||||
@post.reload
|
@post.reload
|
||||||
assert_equal(1, @post.score)
|
assert_equal(1, @post.score)
|
||||||
|
|||||||
@@ -14,36 +14,36 @@ class UserFeedbackTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
should "create a dmail" do
|
should "create a dmail" do
|
||||||
user = FactoryGirl.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
privileged = FactoryGirl.create(:privileged_user)
|
gold = FactoryGirl.create(:gold_user)
|
||||||
member = FactoryGirl.create(:user)
|
member = FactoryGirl.create(:user)
|
||||||
|
|
||||||
CurrentUser.user = privileged
|
CurrentUser.user = gold
|
||||||
assert_difference("Dmail.count", 2) do
|
assert_difference("Dmail.count", 2) do
|
||||||
FactoryGirl.create(:user_feedback, :user => user)
|
FactoryGirl.create(:user_feedback, :user => user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not validate if the creator is the user" do
|
should "not validate if the creator is the user" do
|
||||||
privileged_user = FactoryGirl.create(:privileged_user)
|
gold_user = FactoryGirl.create(:gold_user)
|
||||||
CurrentUser.user = privileged_user
|
CurrentUser.user = gold_user
|
||||||
feedback = FactoryGirl.build(:user_feedback, :user => privileged_user)
|
feedback = FactoryGirl.build(:user_feedback, :user => gold_user)
|
||||||
feedback.save
|
feedback.save
|
||||||
assert_equal(["You cannot submit feedback for yourself"], feedback.errors.full_messages)
|
assert_equal(["You cannot submit feedback for yourself"], feedback.errors.full_messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not validate if the creator is not privileged" do
|
should "not validate if the creator is not gold" do
|
||||||
user = FactoryGirl.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
privileged = FactoryGirl.create(:privileged_user)
|
gold = FactoryGirl.create(:gold_user)
|
||||||
member = FactoryGirl.create(:user)
|
member = FactoryGirl.create(:user)
|
||||||
|
|
||||||
CurrentUser.user = privileged
|
CurrentUser.user = gold
|
||||||
feedback = FactoryGirl.create(:user_feedback, :user => user)
|
feedback = FactoryGirl.create(:user_feedback, :user => user)
|
||||||
assert(feedback.errors.empty?)
|
assert(feedback.errors.empty?)
|
||||||
|
|
||||||
CurrentUser.user = member
|
CurrentUser.user = member
|
||||||
feedback = FactoryGirl.build(:user_feedback, :user => user)
|
feedback = FactoryGirl.build(:user_feedback, :user => user)
|
||||||
feedback.save
|
feedback.save
|
||||||
assert_equal(["You must be privileged"], feedback.errors.full_messages)
|
assert_equal(["You must be gold"], feedback.errors.full_messages)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
should "limit comments" do
|
should "limit comments" do
|
||||||
assert(!@user.can_comment?)
|
assert(!@user.can_comment?)
|
||||||
@user.update_column(:level, User::Levels::PRIVILEGED)
|
@user.update_column(:level, User::Levels::GOLD)
|
||||||
assert(@user.can_comment?)
|
assert(@user.can_comment?)
|
||||||
@user.update_column(:level, User::Levels::MEMBER)
|
@user.update_column(:level, User::Levels::MEMBER)
|
||||||
@user.update_column(:created_at, 1.year.ago)
|
@user.update_column(:created_at, 1.year.ago)
|
||||||
@@ -124,42 +124,42 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
assert(user.is_moderator?)
|
assert(user.is_moderator?)
|
||||||
assert(user.is_janitor?)
|
assert(user.is_janitor?)
|
||||||
assert(user.is_contributor?)
|
assert(user.is_contributor?)
|
||||||
assert(user.is_privileged?)
|
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_janitor?)
|
||||||
assert(user.is_contributor?)
|
assert(user.is_contributor?)
|
||||||
assert(user.is_privileged?)
|
assert(user.is_gold?)
|
||||||
|
|
||||||
user = FactoryGirl.create(:user, :level => User::Levels::JANITOR)
|
user = FactoryGirl.create(:user, :level => User::Levels::JANITOR)
|
||||||
assert(!user.is_admin?)
|
assert(!user.is_admin?)
|
||||||
assert(!user.is_moderator?)
|
assert(!user.is_moderator?)
|
||||||
assert(user.is_janitor?)
|
assert(user.is_janitor?)
|
||||||
assert(user.is_contributor?)
|
assert(user.is_contributor?)
|
||||||
assert(user.is_privileged?)
|
assert(user.is_gold?)
|
||||||
|
|
||||||
user = FactoryGirl.create(:user, :level => User::Levels::CONTRIBUTOR)
|
user = FactoryGirl.create(:user, :level => User::Levels::CONTRIBUTOR)
|
||||||
assert(!user.is_admin?)
|
assert(!user.is_admin?)
|
||||||
assert(!user.is_moderator?)
|
assert(!user.is_moderator?)
|
||||||
assert(!user.is_janitor?)
|
assert(!user.is_janitor?)
|
||||||
assert(user.is_contributor?)
|
assert(user.is_contributor?)
|
||||||
assert(user.is_privileged?)
|
assert(user.is_gold?)
|
||||||
|
|
||||||
user = FactoryGirl.create(:user, :level => User::Levels::PRIVILEGED)
|
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_janitor?)
|
||||||
assert(!user.is_contributor?)
|
assert(!user.is_contributor?)
|
||||||
assert(user.is_privileged?)
|
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_janitor?)
|
||||||
assert(!user.is_contributor?)
|
assert(!user.is_contributor?)
|
||||||
assert(!user.is_privileged?)
|
assert(!user.is_gold?)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "name" do
|
context "name" do
|
||||||
|
|||||||
Reference in New Issue
Block a user