From f56ae86b5b4dafb3d82586a05c3f72fead39e036 Mon Sep 17 00:00:00 2001 From: albert Date: Fri, 16 Sep 2011 19:01:40 -0400 Subject: [PATCH] refactored anon pools --- INSTALL.debian | 11 ++--------- app/models/pool.rb | 3 +-- test/unit/pool_test.rb | 8 ++++++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/INSTALL.debian b/INSTALL.debian index 771c57ce2..b187e7e35 100644 --- a/INSTALL.debian +++ b/INSTALL.debian @@ -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 diff --git a/app/models/pool.rb b/app/models/pool.rb index 706948775..68b3eb34b 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -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 diff --git a/test/unit/pool_test.rb b/test/unit/pool_test.rb index fa20b73a2..73a7bd22d 100644 --- a/test/unit/pool_test.rb +++ b/test/unit/pool_test.rb @@ -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