update factories + tests
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
module Maintenance
|
||||
extend self
|
||||
module_function
|
||||
|
||||
def hourly
|
||||
UploadErrorChecker.new.check!
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
class Comment < ApplicationRecord
|
||||
include Mentionable
|
||||
|
||||
validate :validate_post_exists, :on => :create
|
||||
validate :validate_creator_is_not_limited, :on => :create
|
||||
validates_presence_of :body, :message => "has no content"
|
||||
belongs_to :post
|
||||
|
||||
@@ -5,7 +5,7 @@ class Note < ApplicationRecord
|
||||
belongs_to :post
|
||||
belongs_to_creator
|
||||
has_many :versions, -> {order("note_versions.id ASC")}, :class_name => "NoteVersion", :dependent => :destroy
|
||||
validates_presence_of :post_id, :creator_id, :x, :y, :width, :height, :body
|
||||
validates_presence_of :creator_id, :x, :y, :width, :height, :body
|
||||
validate :post_must_exist
|
||||
validate :note_within_image
|
||||
after_save :update_post
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FactoryBot.define do
|
||||
factory(:artist) do
|
||||
name {rand(1_000_000).to_s}
|
||||
is_active true
|
||||
name { rand(1_000_000).to_s }
|
||||
is_active { true }
|
||||
association :creator, factory: :user
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,6 @@ FactoryBot.define do
|
||||
factory(:ban) do |f|
|
||||
banner :factory => :admin_user
|
||||
reason {FFaker::Lorem.words.join(" ")}
|
||||
duration 60
|
||||
duration {60}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FactoryBot.define do
|
||||
factory(:bulk_update_request) do |f|
|
||||
title "xxx"
|
||||
script "create alias aaa -> bbb"
|
||||
skip_secondary_validations true
|
||||
title {"xxx"}
|
||||
script {"create alias aaa -> bbb"}
|
||||
skip_secondary_validations {true}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FactoryBot.define do
|
||||
factory(:comment_vote) do
|
||||
score 1
|
||||
score {1}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
FactoryBot.define do
|
||||
factory(:forum_subscription) do
|
||||
end
|
||||
factory(:forum_subscription)
|
||||
end
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
FactoryBot.define do
|
||||
factory(:forum_topic) do
|
||||
title {FFaker::Lorem.words.join(" ")}
|
||||
is_sticky false
|
||||
is_locked false
|
||||
category_id 0
|
||||
is_sticky {false}
|
||||
is_locked {false}
|
||||
category_id {0}
|
||||
|
||||
factory(:mod_up_forum_topic) do
|
||||
min_level User::Levels::MODERATOR
|
||||
min_level {User::Levels::MODERATOR}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
FactoryBot.define do
|
||||
factory(:forum_topic_visit) do
|
||||
end
|
||||
factory(:forum_topic_visit)
|
||||
end
|
||||
|
||||
@@ -2,6 +2,6 @@ FactoryBot.define do
|
||||
factory(:ip_ban) do
|
||||
creator :factory => :user
|
||||
reason {FFaker::Lorem.words.join(" ")}
|
||||
ip_addr "127.0.0.2"
|
||||
ip_addr {"127.0.0.2"}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
FactoryBot.define do
|
||||
factory(:mod_action) do
|
||||
creator :factory => :user
|
||||
description "1234"
|
||||
description {"1234"}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FactoryBot.define do
|
||||
factory(:news_update) do
|
||||
message "xxx"
|
||||
message {"xxx"}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
FactoryBot.define do
|
||||
factory(:note) do
|
||||
post
|
||||
x 1
|
||||
y 1
|
||||
width 1
|
||||
height 1
|
||||
is_active true
|
||||
body {FFaker::Lorem.sentences.join(" ")}
|
||||
x { 1 }
|
||||
y { 1 }
|
||||
width { 1 }
|
||||
height { 1 }
|
||||
is_active { true }
|
||||
body { FFaker::Lorem.sentences.join(" ") }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,15 +4,15 @@ FactoryBot.define do
|
||||
n.to_s
|
||||
end
|
||||
uploader :factory => :user
|
||||
uploader_ip_addr "127.0.0.1"
|
||||
tag_string "tag1 tag2"
|
||||
tag_count 2
|
||||
tag_count_general 2
|
||||
file_ext "jpg"
|
||||
image_width 1500
|
||||
image_height 1000
|
||||
file_size 2000
|
||||
rating "q"
|
||||
uploader_ip_addr {"127.0.0.1"}
|
||||
tag_string {"tag1 tag2"}
|
||||
tag_count {2}
|
||||
tag_count_general {2}
|
||||
file_ext {"jpg"}
|
||||
image_width {1500}
|
||||
image_height {1000}
|
||||
file_size {2000}
|
||||
rating {"q"}
|
||||
source { FFaker::Internet.http_url }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FactoryBot.define do
|
||||
factory(:post_appeal) do
|
||||
reason "xxx"
|
||||
reason {"xxx"}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
FactoryBot.define do
|
||||
factory(:post_flag) do
|
||||
reason "xxx"
|
||||
is_resolved false
|
||||
reason {"xxx"}
|
||||
is_resolved {false}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
FactoryBot.define do
|
||||
factory(:tag) do
|
||||
name {"#{FFaker::Name.first_name.downcase}#{rand(1000)}"}
|
||||
post_count 0
|
||||
post_count {0}
|
||||
category {Tag.categories.general}
|
||||
related_tags ""
|
||||
related_tags {""}
|
||||
related_tags_updated_at {Time.now}
|
||||
|
||||
factory(:artist_tag) do
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
FactoryBot.define do
|
||||
factory :tag_alias do
|
||||
antecedent_name "aaa"
|
||||
consequent_name "bbb"
|
||||
status "active"
|
||||
skip_secondary_validations true
|
||||
antecedent_name {"aaa"}
|
||||
consequent_name {"bbb"}
|
||||
status {"active"}
|
||||
skip_secondary_validations {true}
|
||||
creator_ip_addr { FFaker::Internet.ip_v4_address }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
FactoryBot.define do
|
||||
factory :tag_implication do
|
||||
antecedent_name "aaa"
|
||||
consequent_name "bbb"
|
||||
status "active"
|
||||
skip_secondary_validations true
|
||||
antecedent_name {"aaa"}
|
||||
consequent_name {"bbb"}
|
||||
status {"active"}
|
||||
skip_secondary_validations {true}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,16 +2,16 @@ require 'fileutils'
|
||||
|
||||
FactoryBot.define do
|
||||
factory(:upload) do
|
||||
rating "s"
|
||||
rating {"s"}
|
||||
uploader :factory => :user, :level => 20
|
||||
uploader_ip_addr "127.0.0.1"
|
||||
tag_string "special"
|
||||
status "pending"
|
||||
server Socket.gethostname
|
||||
source "xxx"
|
||||
uploader_ip_addr {"127.0.0.1"}
|
||||
tag_string {"special"}
|
||||
status {"pending"}
|
||||
server {Socket.gethostname}
|
||||
source {"xxx"}
|
||||
|
||||
factory(:source_upload) do
|
||||
source "http://www.google.com/intl/en_ALL/images/logo.gif"
|
||||
source {"http://www.google.com/intl/en_ALL/images/logo.gif"}
|
||||
end
|
||||
|
||||
factory(:ugoira_upload) do
|
||||
|
||||
@@ -3,61 +3,61 @@ FactoryBot.define do
|
||||
sequence :name do |n|
|
||||
"user#{n}"
|
||||
end
|
||||
password "password"
|
||||
password {"password"}
|
||||
password_hash {User.sha1("password")}
|
||||
email {FFaker::Internet.email}
|
||||
default_image_size "large"
|
||||
base_upload_limit 10
|
||||
level 20
|
||||
default_image_size {"large"}
|
||||
base_upload_limit {10}
|
||||
level {20}
|
||||
created_at {Time.now}
|
||||
last_logged_in_at {Time.now}
|
||||
favorite_count 0
|
||||
bit_prefs 0
|
||||
favorite_count {0}
|
||||
bit_prefs {0}
|
||||
|
||||
factory(:banned_user) do
|
||||
transient { ban_duration 3 }
|
||||
is_banned true
|
||||
transient { ban_duration {3} }
|
||||
is_banned {true}
|
||||
end
|
||||
|
||||
factory(:member_user) do
|
||||
level 20
|
||||
level {20}
|
||||
end
|
||||
|
||||
factory(:gold_user) do
|
||||
level 30
|
||||
level {30}
|
||||
end
|
||||
|
||||
factory(:platinum_user) do
|
||||
level 31
|
||||
level {31}
|
||||
end
|
||||
|
||||
factory(:builder_user) do
|
||||
level 32
|
||||
level {32}
|
||||
end
|
||||
|
||||
factory(:contributor_user) do
|
||||
level 32
|
||||
bit_prefs User.flag_value_for("can_upload_free")
|
||||
level {32}
|
||||
bit_prefs {User.flag_value_for("can_upload_free")}
|
||||
end
|
||||
|
||||
factory(:contrib_user) do
|
||||
level 32
|
||||
bit_prefs User.flag_value_for("can_upload_free")
|
||||
level {32}
|
||||
bit_prefs {User.flag_value_for("can_upload_free")}
|
||||
end
|
||||
|
||||
factory(:moderator_user) do
|
||||
level 40
|
||||
can_approve_posts true
|
||||
level {40}
|
||||
can_approve_posts {true}
|
||||
end
|
||||
|
||||
factory(:mod_user) do
|
||||
level 40
|
||||
can_approve_posts true
|
||||
level {40}
|
||||
can_approve_posts {true}
|
||||
end
|
||||
|
||||
factory(:admin_user) do
|
||||
level 50
|
||||
can_approve_posts true
|
||||
level {50}
|
||||
can_approve_posts {true}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FactoryBot.define do
|
||||
factory(:user_feedback) do
|
||||
user
|
||||
category "positive"
|
||||
body {FFaker::Lorem.words.join(" ")}
|
||||
category { "positive" }
|
||||
body { FFaker::Lorem.words.join(" ") }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -89,7 +89,8 @@ class CommentTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "fail creation" do
|
||||
comment = FactoryBot.build(:comment)
|
||||
post = FactoryBot.create(:post)
|
||||
comment = FactoryBot.build(:comment, post: post)
|
||||
comment.save
|
||||
assert_equal(["You can not post comments within 1 week of sign up"], comment.errors.full_messages)
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class NoteSanitizerTest < ActiveSupport::TestCase
|
||||
context "Sanitizing a note" do
|
||||
should "strip unsafe tags" do
|
||||
body = '<p>test</p> <script>alert("owned")</script>'
|
||||
assert_equal('<p>test</p> alert("owned")', NoteSanitizer.sanitize(body))
|
||||
assert_equal('<p>test</p> ', NoteSanitizer.sanitize(body))
|
||||
end
|
||||
|
||||
should "strip unsafe css" do
|
||||
|
||||
@@ -68,7 +68,7 @@ class NoteTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "not validate if the body is blank" do
|
||||
@note = FactoryBot.build(:note, body: " ")
|
||||
@note = FactoryBot.build(:note, body: " ", :post => @post)
|
||||
|
||||
assert_equal(false, @note.valid?)
|
||||
assert_equal(["Body can't be blank"], @note.errors.full_messages)
|
||||
|
||||
Reference in New Issue
Block a user