Skip to content
Extraits de code Groupes Projets
Valider f0df1ec8 rédigé par Raphael's avatar Raphael
Parcourir les fichiers

Remove dev utilities controller

parent c07b9b18
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# 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
...@@ -37,20 +37,12 @@ Diaspora::Application.routes.draw do ...@@ -37,20 +37,12 @@ Diaspora::Application.routes.draw do
match 'aspects/manage', :to => 'aspects#manage' match 'aspects/manage', :to => 'aspects#manage'
resources :aspects, :except => [:edit] 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 #public routes
match 'webfinger', :to => 'publics#webfinger' match 'webfinger', :to => 'publics#webfinger'
match 'hcard/users/:id', :to => 'publics#hcard' match 'hcard/users/:id', :to => 'publics#hcard'
match '.well-known/host-meta',:to => 'publics#host_meta' match '.well-known/host-meta',:to => 'publics#host_meta'
match 'receive/users/:id', :to => 'publics#receive' match 'receive/users/:id', :to => 'publics#receive'
match 'hub', :to => 'publics#hub' match 'hub', :to => 'publics#hub'
#match 'log', :to => "dev_utilities#log"
#root #root
root :to => 'home#show' root :to => 'home#show'
......
# 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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter