diff --git a/app/models/invitation_code.rb b/app/models/invitation_code.rb index e653648ce551ee2c3bf18dc4325ff6e8a42e1632..21bb1a74e4637b827145f38933be37d2ad4d49d9 100644 --- a/app/models/invitation_code.rb +++ b/app/models/invitation_code.rb @@ -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 diff --git a/app/models/photo.rb b/app/models/photo.rb index 54b3a9f6bc6d926b1b4b96511b6975cf1fb54a2e..fa76787c51b4f4363a603804a5c3a77afe4a7710 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -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) diff --git a/app/models/user.rb b/app/models/user.rb index 6d7abfb7c24860b1967e7c9f80b2ed4bbf50b530..2ca3d6bb869082a2843b13fd7e1710f0e1d99721 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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) diff --git a/lib/diaspora/guid.rb b/lib/diaspora/guid.rb index 3a7b1d54d24f9811201e9bbc92959bc488edd6ed..c94e56eacd6ec7eb6272d1faddfc1d9da5338f31 100644 --- a/lib/diaspora/guid.rb +++ b/lib/diaspora/guid.rb @@ -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 diff --git a/lib/tasks/generate_session_secret.rake b/lib/tasks/generate_session_secret.rake index f6a1e85b546a4f864373ccea9e6a50205197d428..efd55bbabd4def7f6c503e6b050a7463716ce8a2 100644 --- a/lib/tasks/generate_session_secret.rake +++ b/lib/tasks/generate_session_secret.rake @@ -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 diff --git a/lib/tasks/heroku.rake b/lib/tasks/heroku.rake index 3b702d7fc0393dcf8bc3be1262bae7020353050d..32ca1a78166af9f911e742d4853ca21ef548e822 100644 --- a/lib/tasks/heroku.rake +++ b/lib/tasks/heroku.rake @@ -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 diff --git a/spec/factories.rb b/spec/factories.rb index 4f13b6ec636589ea484b67f7006aa912b06865cf..bde89c3c0fcb89bc3c5cc51647468fab50c513b5 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -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 diff --git a/spec/models/services/twitter_spec.rb b/spec/models/services/twitter_spec.rb index e990a317526b38b02d989c24f26c4428a88ef2b3..cccd190948e4b15be13a0426867cbdcc367e04a2 100644 --- a/spec/models/services/twitter_spec.rb +++ b/spec/models/services/twitter_spec.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 1738beda5c98f41807f14a4f52217f87008265db..30a29e910f0443e80fb1e22b71e31f58947f24e9 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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