remove ActiveSupport::SecureRandom

This commit is contained in:
Maxwell Salzberg 2012-03-16 18:10:18 -07:00 committed by danielgrippi
parent 3c23364fbc
commit a2aabeb599
9 changed files with 15 additions and 15 deletions

View file

@ -23,7 +23,7 @@ class InvitationCode < ActiveRecord::Base
def generate_token
begin
self.token = ActiveSupport::SecureRandom.hex(6)
self.token = SecureRandom.hex(6)
end while InvitationCode.exists?(:token => self[:token])
end

View file

@ -71,7 +71,7 @@ class Photo < ActiveRecord::Base
photo.pending = params[:pending] if params[:pending]
photo.diaspora_handle = photo.author.diaspora_handle
photo.random_string = ActiveSupport::SecureRandom.hex(10)
photo.random_string = SecureRandom.hex(10)
if params[:user_file]
image_file = params.delete(:user_file)

View file

@ -438,7 +438,7 @@ class User < ActiveRecord::Base
self.unconfirmed_email = nil if unconfirmed_email.blank? || unconfirmed_email == email
if unconfirmed_email_changed?
self.confirm_email_token = unconfirmed_email ? ActiveSupport::SecureRandom.hex(15) : nil
self.confirm_email_token = unconfirmed_email ? SecureRandom.hex(15) : nil
end
end
@ -495,7 +495,7 @@ class User < ActiveRecord::Base
end
self[:email] = "deletedaccount_#{self[:id]}@example.org"
random_password = ActiveSupport::SecureRandom.hex(20)
random_password = SecureRandom.hex(20)
self.password = random_password
self.password_confirmation = random_password
self.save(:validate => false)

View file

@ -13,6 +13,6 @@ module Diaspora::Guid
# @return [String] The model's guid.
def set_guid
self.guid = ActiveSupport::SecureRandom.hex(8) if self.guid.blank?
self.guid = SecureRandom.hex(8) if self.guid.blank?
end
end

View file

@ -3,7 +3,7 @@ namespace :generate do
task :secret_token do
path = File.join(Rails.root, 'config', 'initializers', 'secret_token.rb')
secret = ActiveSupport::SecureRandom.hex(40)
secret = SecureRandom.hex(40)
File.open(path, 'w') do |f|
f.write <<"EOF"
# Copyright (c) 2010-2011, Diaspora Inc. This file is

View file

@ -9,7 +9,7 @@ namespace :heroku do
task :generate_secret_token do
puts "Generating and setting a new secret token"
token = ActiveSupport::SecureRandom.hex(40)#reloads secret token every time you reload vars.... this expires cookies, and kinda sucks
token = SecureRandom.hex(40)#reloads secret token every time you reload vars.... this expires cookies, and kinda sucks
command = "#{HEROKU_CONFIG_ADD_COMMAND} SECRET_TOKEN=#{token}"
puts command
system command

View file

@ -7,7 +7,7 @@
# http://railscasts.com/episodes/158-factories-not-fixtures
def r_str
ActiveSupport::SecureRandom.hex(3)
SecureRandom.hex(3)
end
FactoryGirl.define do
@ -100,7 +100,7 @@ FactoryGirl.define do
end
factory(:photo) do
sequence(:random_string) {|n| ActiveSupport::SecureRandom.hex(10) }
sequence(:random_string) {|n| SecureRandom.hex(10) }
association :author, :factory => :person
after_build do |p|
p.unprocessed_image.store! File.open(File.join(File.dirname(__FILE__), 'fixtures', 'button.png'))
@ -237,7 +237,7 @@ FactoryGirl.define do
end
factory(:note, :parent => :status_message) do
text ActiveSupport::SecureRandom.hex(1000)
text SecureRandom.hex(1000)
end
factory(:rich_media, :parent => :status_message) do

View file

@ -30,17 +30,17 @@ describe Services::Twitter do
end
describe "message size limits" do
before :each do
@long_message_start = ActiveSupport::SecureRandom.hex(25)
@long_message_end = ActiveSupport::SecureRandom.hex(25)
@long_message_start = SecureRandom.hex(25)
@long_message_end = SecureRandom.hex(25)
end
it "should not truncate a short message" do
short_message = ActiveSupport::SecureRandom.hex(20)
short_message = SecureRandom.hex(20)
short_post = stub(:text => short_message )
@service.public_message(short_post, '').should == short_message
end
it "should truncate a long message" do
long_message = ActiveSupport::SecureRandom.hex(220)
long_message = SecureRandom.hex(220)
long_post = stub(:text => long_message )
@service.public_message(long_post, '').should == long_message.first(137) + "..."
end

View file

@ -846,7 +846,7 @@ describe User do
describe "#clear_account!" do
it 'resets the password to a random string' do
random_pass = "12345678909876543210"
ActiveSupport::SecureRandom.should_receive(:hex).and_return(random_pass)
SecureRandom.should_receive(:hex).and_return(random_pass)
@user.clear_account!
@user.valid_password?(random_pass)
end