diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb deleted file mode 100644 index d0c6320da7c734ceb958521542ec187b1a909949..0000000000000000000000000000000000000000 --- a/app/controllers/dev_utilities_controller.rb +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright (c) 2010, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - -require File.join(Rails.root, 'lib/em-webfinger') -class DevUtilitiesController < ApplicationController - before_filter :authenticate_user!, :except => [:set_backer_number, :log] - include ApplicationHelper - include RequestsHelper - - def zombiefriends - render :nothing => true - bkr_info = backer_info - if current_user.email == "tom@tom.joindiaspora.com" - puts bkr_info.inspect - bkr_info.each do |backer| - backer_email = "#{backer['username']}@#{backer['username']}.joindiaspora.com" - - webfinger = EMWebfinger.new(backer_email) - - webfinger.on_person { |person| - puts person.inspect - if person.respond_to? :diaspora_handle - rel_hash = {:person => person} - logger.info "Zombiefriending #{backer['given_name']} #{backer['family_name']}" - logger.info "Calling send_contact_request with #{rel_hash[:person]} and #{current_user.aspects.first}" - begin - - - current_user.send_contact_request_to(rel_hash[:person], current_user.aspects.first) - rescue Exception => e - logger.info e.inspect - puts e.inspect - end - else - puts "error: #{person}" - end - } - end - end - end - - def zombiefriendaccept - render :nothing => true - Request.all.each{|r| - current_user.accept_and_respond(r.id, current_user.aspects.first.id) - } - end - - def set_backer_number - render :nothing => true - seed_num_hash = {:seed_number => params[:number]} - file = File.new(Rails.root.join('config','backer_number.yml'),'w') - file.write(seed_num_hash.to_yaml) - file.close - end - - def set_profile_photo - render :nothing => true - - backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i - username = backer_info[backer_number]['username'].gsub(/ /,'').downcase - - @fixture_name = File.join(File.dirname(__FILE__), "..", "..", "public", "images", "user", "#{username}.jpg") - - photo = current_user.post(:photo, :user_file => File.open(@fixture_name), :to => 'all') - photo.save - - current_user.raw_visible_posts << photo - current_user.save - - current_user.update_profile(:image_url => photo.url(:thumb_large)) - current_user.save - end - - def log - @log = `tail -n 200 log/development.log` - - render "shared/log" - end - - protected - - def backer_info - config = YAML.load_file(File.join(File.dirname(__FILE__), "..", "..", "config", "deploy_config.yml")) - config['servers']['backer'] - end -end diff --git a/config/routes.rb b/config/routes.rb index b193b001771f9df27d1b4d5776a81897e3844cd2..a8f0b2e879a42f428cbae3490a5f538b43ff8048 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,20 +37,12 @@ Diaspora::Application.routes.draw do match 'aspects/manage', :to => 'aspects#manage' resources :aspects, :except => [:edit] - #match 'warzombie', :to => "dev_utilities#warzombie" - #match 'zombiefriends', :to => "dev_utilities#zombiefriends" - #match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept" - #match 'set_backer_number', :to => "dev_utilities#set_backer_number" - #match 'set_profile_photo', :to => "dev_utilities#set_profile_photo" - #public routes match 'webfinger', :to => 'publics#webfinger' match 'hcard/users/:id', :to => 'publics#hcard' match '.well-known/host-meta',:to => 'publics#host_meta' match 'receive/users/:id', :to => 'publics#receive' match 'hub', :to => 'publics#hub' - #match 'log', :to => "dev_utilities#log" - #root root :to => 'home#show' diff --git a/spec/controllers/dev_utilities_controller_spec.rb b/spec/controllers/dev_utilities_controller_spec.rb deleted file mode 100644 index 5e945a1c7e1ebc072dcb78ab52050e10dd9d0fd9..0000000000000000000000000000000000000000 --- a/spec/controllers/dev_utilities_controller_spec.rb +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (c) 2010, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - -require File.join(File.dirname(__FILE__), "..", "spec_helper") - -describe DevUtilitiesController do - render_views - - before do - @tom = Factory.create(:user_with_aspect, :email => "tom@tom.joindiaspora.org") - sign_in :user, @tom - end - - describe "#zombiefriends" do - it "succeeds" do - pending - get :zombiefriends - response.should be_success - end - end - - describe "operations that affect config/backer_number.yml" do - # In case anyone wants their config/backer_number.yml to still exist after running specs - before do - @backer_number_file = File.join(File.dirname(__FILE__), "..", "..", "config", "backer_number.yml") - @temp_file = File.join(File.dirname(__FILE__), "..", "..", "config", "backer_number.yml-tmp") - FileUtils.mv(@backer_number_file, @temp_file, :force => true) if File.exists?(@backer_number_file) - end - after do - if File.exists?(@temp_file) - FileUtils.mv(@temp_file, @backer_number_file, :force => true) - else - FileUtils.rm_rf(@backer_number_file) - end - end - - describe "#set_backer_number" do - it "creates a file containing the seed number" do - pending - File.should_not exist(@backer_number_file) - get :set_backer_number, 'number' => '3' - File.should exist(@backer_number_file) - YAML.load_file(@backer_number_file)[:seed_number].to_i.should == 3 - end - end - - describe "#set_profile_photo" do - before do - config = YAML.load_file(File.join(File.dirname(__FILE__), "..", "..", "config", "deploy_config.yml")) - seed_numbers = config["servers"]["backer"].map {|b| b["number"] } - @good_number = seed_numbers.max - @bad_number = @good_number + 1 - end - it "succeeds when a backer with the seed number exists" do - pending - get :set_backer_number, 'number' => @good_number.to_s - get :set_profile_photo - response.should be_success - end - it "fails when a backer with the seed number does not exist" do - pending - get :set_backer_number, 'number' => @bad_number.to_s - lambda { get :set_profile_photo }.should raise_error - end - end - end -end