fixed tests

This commit is contained in:
albert
2011-10-22 19:01:27 -04:00
parent 5444ad5107
commit 0de90d487b
10 changed files with 19 additions and 24 deletions

View File

@@ -13,6 +13,7 @@ class Artist < ActiveRecord::Base
has_one :tag_alias, :foreign_key => "antecedent_name", :primary_key => "name"
accepts_nested_attributes_for :wiki_page
attr_accessible :name, :url_string, :other_names, :group_name, :wiki_page_attributes, :notes, :is_active
attr_accessible :name, :url_string, :other_names, :group_name, :wiki_page_attributes, :notes, :is_active, :as => [:member, :moderator]
attr_accessible :name, :url_string, :other_names, :group_name, :wiki_page_attributes, :notes, :is_active, :is_banned, :as => :admin
scope :url_match, lambda {|string| where(["id in (?)", Artist.find_all_by_url(string).map(&:id)])}
scope :other_names_match, lambda {|string| where(["other_names_index @@ to_tsquery('danbooru', ?)", Artist.normalize_name(string)])}

View File

@@ -1,6 +1,7 @@
class ForumPost < ActiveRecord::Base
attr_accessible :body, :topic_id
attr_accessible :body, :topic_id, :is_locked, :is_sticky, :as => [:admin, :moderator, :janitor]
attr_accessible :body, :topic_id, :as => [:member]
attr_accessible :body, :topic_id, :is_locked, :is_sticky, :as => [:admin, :moderator]
belongs_to :creator, :class_name => "User"
belongs_to :topic, :class_name => "ForumTopic"
before_validation :initialize_creator, :on => :create

View File

@@ -1,6 +1,7 @@
class ForumTopic < ActiveRecord::Base
attr_accessible :title, :original_post_attributes
attr_accessible :title, :original_post_attributes, :is_sticky, :is_locked, :as => [:admin, :moderator, :janitor]
attr_accessible :title, :original_post_attributes, :as => [:member]
attr_accessible :title, :original_post_attributes, :is_sticky, :is_locked, :as => [:admin, :moderator]
belongs_to :creator, :class_name => "User"
belongs_to :updater, :class_name => "User"
has_many :posts, :class_name => "ForumPost", :order => "forum_posts.id asc", :foreign_key => "topic_id", :dependent => :destroy

View File

@@ -31,7 +31,8 @@ class Post < ActiveRecord::Base
validates_presence_of :parent, :if => lambda {|rec| !rec.parent_id.nil?}
validate :validate_parent_does_not_have_a_parent
attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at, :parent_id
attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at, :parent_id, :is_rating_locked, :is_note_locked, :as => [:admin, :moderator, :janitor]
attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at, :parent_id, :as => [:member]
attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at, :parent_id, :is_rating_locked, :is_note_locked, :as => [:admin, :moderator]
scope :pending, where(["is_pending = ?", true])
scope :pending_or_flagged, where(["(is_pending = ? OR is_flagged = ?)", true, true])
scope :undeleted, where(["is_deleted = ?", false])

View File

@@ -15,6 +15,7 @@ class User < ActiveRecord::Base
attr_accessor :password, :old_password
attr_accessible :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
attr_accessible :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, :as => [:moderator, :member]
attr_accessible :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, :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"
@@ -217,19 +218,10 @@ class User < ActiveRecord::Base
def role
case level
when Levels::MEMBER
when Levels::MEMBER, Levels::PRIVILEGED, Levels::CONTRIBUTOR
:member
when Levels::PRIVILEGED
:privileged
when Levels::CONTRIBUTOR
:contributor
when Levels::JANITOR
:janitor
when Levels::MODERATOR
when Levels::MODERATOR, Levels::JANITOR
:moderator
when Levels::ADMIN