Commit a2aabeb5 authored by Maxwell Salzberg's avatar Maxwell Salzberg Committed by danielgrippi

remove ActiveSupport::SecureRandom

parent 3c23364f
......@@ -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
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment