refactored anon pools
This commit is contained in:
@@ -15,9 +15,6 @@ echo "It will create a new user called danbooru which will run the Danbooru"
|
||||
echo "processes. It will download the latest copy and install it in"
|
||||
echo "/var/www/danbooru."
|
||||
echo
|
||||
echo "It is mostly automated but you will receive some prompts when installing"
|
||||
echo "Passenger towards the end of the script."
|
||||
echo
|
||||
echo -n "Enter the hostname for this server (ex: danbooru.donmai.us): "
|
||||
read HOSTNAME
|
||||
|
||||
@@ -64,12 +61,8 @@ gem install --no-ri --no-rdoc bundler
|
||||
|
||||
# Install Passenger
|
||||
gem install --no-ri --no-rdoc -v 3.0.9 passenger
|
||||
rvm exec passenger-install-nginx-module -a
|
||||
rm /opt/nginx/conf/*.default
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
rvm exec passenger-install-nginx-module --auto --auto-download --prefix=/opt
|
||||
rm -f /opt/nginx/conf/*.default
|
||||
|
||||
# Create user account
|
||||
useradd -m danbooru
|
||||
|
||||
@@ -24,10 +24,9 @@ class Pool < ActiveRecord::Base
|
||||
select_value_sql("SELECT name FROM pools WHERE id = ?", id)
|
||||
end
|
||||
|
||||
def self.create_anonymous(creator, creator_ip_addr)
|
||||
def self.create_anonymous
|
||||
Pool.new do |pool|
|
||||
pool.name = "TEMP:#{Time.now.to_f}.#{rand(1_000_000)}"
|
||||
pool.creator = creator
|
||||
pool.save
|
||||
pool.name = "anon:#{pool.id}"
|
||||
pool.save
|
||||
|
||||
@@ -248,9 +248,13 @@ class PoolTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
context "An anonymous pool" do
|
||||
should "have a name starting with anon" do
|
||||
setup do
|
||||
user = Factory.create(:user)
|
||||
pool = Pool.create_anonymous(user, "127.0.0.1")
|
||||
CurrentUser.user = user
|
||||
end
|
||||
|
||||
should "have a name starting with anon" do
|
||||
pool = Pool.create_anonymous
|
||||
assert_match(/^anon:\d+$/, pool.name)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user