refactored anon pools

This commit is contained in:
albert
2011-09-16 19:01:40 -04:00
parent d664cca4a4
commit f56ae86b5b
3 changed files with 9 additions and 13 deletions

View File

@@ -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 "processes. It will download the latest copy and install it in"
echo "/var/www/danbooru." echo "/var/www/danbooru."
echo 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): " echo -n "Enter the hostname for this server (ex: danbooru.donmai.us): "
read HOSTNAME read HOSTNAME
@@ -64,12 +61,8 @@ gem install --no-ri --no-rdoc bundler
# Install Passenger # Install Passenger
gem install --no-ri --no-rdoc -v 3.0.9 passenger gem install --no-ri --no-rdoc -v 3.0.9 passenger
rvm exec passenger-install-nginx-module -a rvm exec passenger-install-nginx-module --auto --auto-download --prefix=/opt
rm /opt/nginx/conf/*.default rm -f /opt/nginx/conf/*.default
if [ $? -ne 0 ]; then
exit 1
fi
# Create user account # Create user account
useradd -m danbooru useradd -m danbooru

View File

@@ -24,10 +24,9 @@ class Pool < ActiveRecord::Base
select_value_sql("SELECT name FROM pools WHERE id = ?", id) select_value_sql("SELECT name FROM pools WHERE id = ?", id)
end end
def self.create_anonymous(creator, creator_ip_addr) def self.create_anonymous
Pool.new do |pool| Pool.new do |pool|
pool.name = "TEMP:#{Time.now.to_f}.#{rand(1_000_000)}" pool.name = "TEMP:#{Time.now.to_f}.#{rand(1_000_000)}"
pool.creator = creator
pool.save pool.save
pool.name = "anon:#{pool.id}" pool.name = "anon:#{pool.id}"
pool.save pool.save

View File

@@ -248,9 +248,13 @@ class PoolTest < ActiveSupport::TestCase
end end
context "An anonymous pool" do context "An anonymous pool" do
should "have a name starting with anon" do setup do
user = Factory.create(:user) 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) assert_match(/^anon:\d+$/, pool.name)
end end
end end