Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove whitespace

  • Loading branch information...
commit 6eba11a58641bbe0b102ea055d10dfcd5771f044 1 parent f1a1a63
@NARKOZ authored
View
4 lib/vbulletin_rails.rb
@@ -85,7 +85,7 @@ def self.fetch_substr_ip(ip, length = 1)
def self.idhash alt_ip, user_agent
Digest::MD5.hexdigest(user_agent + fetch_substr_ip(alt_ip))
end
-
+
# Cleans everything in VBulletin tables. Used to setup tests.
def self.clean_tables!
VBulletinRails::User.delete_all
@@ -93,5 +93,5 @@ def self.clean_tables!
VBulletinRails::Usertextfield.delete_all
VBulletinRails::Session.delete_all
end
-
+
end
View
24 lib/vbulletin_rails/core_ext.rb
@@ -12,13 +12,13 @@ class Base
# With this method included, two hooks on User are added:
# * When user is created - additional VBulletin account corresponding to user email and password is created, see: add_vbulletin
# * When user is updated - corresponding VBulletin password is updated, see: update_vbulletin
- # * When user is validated - corresponding VBulletin object is validated as well, see: validate_vbulletin
+ # * When user is validated - corresponding VBulletin object is validated as well, see: validate_vbulletin
def self.include_vbulletin
before_validation :validate_vbulletin
before_create :add_vbulletin
after_update :update_vbulletin
end
-
+
# Method used in user processing model to overwrite default column names.
# Normally VBulletinRails assumes, that User model contains columns with names 'email', 'password' and (optional) 'username'.
# If you want to overwrite this, use this method as follows:
@@ -42,12 +42,12 @@ def update_vbulletin
vb_user = VBulletinRails::User.find_by_email(register_parameter_from_user_model(:email))
vb_user.update_attributes(:password => register_parameter_from_user_model(:password))
end
-
+
# Filter launched <tt>before_validation</tt>, won't allow using it model to validate unless VBulletin validates properly
def validate_vbulletin
vb_user = VBulletinRails::User.find_by_email(register_parameter_from_user_model(:email))
unless vb_user
- vb_user = VBulletinRails::User.new(register_parameters_from_user_model)
+ vb_user = VBulletinRails::User.new(register_parameters_from_user_model)
unless vb_user.valid?
vb_user.errors.each do |error, message|
self.errors.add('vbulletin_' + error.to_s, message)
@@ -55,7 +55,7 @@ def validate_vbulletin
end
end
end
-
+
# Returns hash of parameters ready to pass to VBulletinRails::User constructor
def register_parameters_from_user_model
register_parameters = [:email, :password, :username].collect do |vbulletin_column_name|
@@ -68,7 +68,7 @@ def register_parameters_from_user_model
def register_parameter_from_user_model(vbulletin_column_name)
((defined?(@@vbulletin_column_names) && self.respond_to?(@@vbulletin_column_names[vbulletin_column_name])) ? self.send(@@vbulletin_column_names[vbulletin_column_name]) : self.send(vbulletin_column_name))
end
-
+
# Get database configuration options
def self.database_configuration
begin
@@ -83,7 +83,7 @@ def self.db_env
base_env = (defined?(Rails) ? Rails.env : 'test')
database_configuration['vbulletin_' + base_env] ? 'vbulletin_' + base_env : base_env
end
-
+
# Sets connection to VBulletin database. If <tt>vbulletin_<environemt></tt> specified in <tt>database.yml</tt> file, it connets to that database instead of normal database.
# # database.yml
# # Sets VBulletin connetion to another database located in external.com, and assumes that all VBulletin tables have vb_ prefix.
@@ -106,7 +106,7 @@ def self.establish_vbulletin_connection
end
end
end
-
+
# Returns proper prefix for VBulletin tables
def self.get_vbulletin_prefix
((database_configuration[db_env] && database_configuration[db_env]['prefix']) ? database_configuration[db_env]['prefix'] : '')
@@ -144,7 +144,7 @@ def vbulletin_login options = {}
return vb_user
end
-
+
# Destroys VBulletin user session
def vbulletin_logout
VBulletinRails::Session.destroy(cookies[:bb_sessionhash])
@@ -210,7 +210,7 @@ def current_vbulletin_user
end
#:nodoc: all
-module Rails
+module Rails
class Application #:nodoc:
# Add config.vbulletin.<parameter> accessor. Supported parameters are:
@@ -235,7 +235,7 @@ def vbulletin=(value)
module ActiveSupport
class TestCase #:nodoc:
- setup :clean_vbulletin_tables
+ setup :clean_vbulletin_tables
def clean_vbulletin_tables
VBulletinRails.clean_tables!
end
@@ -244,7 +244,7 @@ def clean_vbulletin_tables
module ActionController
class TestCase #:nodoc:
- setup :clean_vbulletin_tables
+ setup :clean_vbulletin_tables
def clean_vbulletin_tables
VBulletinRails.clean_tables!
end
View
2  lib/vbulletin_rails/models/session.rb
@@ -5,7 +5,7 @@ class Session < ActiveRecord::Base
# VBulletin tables prefix in database. It must set same as <tt>$config['Database']['tableprefix']</tt> in your VBulletin forum
PREFIX = get_vbulletin_prefix
- establish_vbulletin_connection
+ establish_vbulletin_connection
# Timeout used to set <tt>last_visit</tt> in database. Taken from VBulletin. Do not touch.
VB_SESSION_TIMEOUT = 900
View
15 lib/vbulletin_rails/models/user.rb
@@ -5,7 +5,7 @@ class User < ActiveRecord::Base
# VBulletin tables prefix in database. It must set same as <tt>$config['Database']['tableprefix']</tt> in your VBulletin forum
PREFIX = get_vbulletin_prefix
- establish_vbulletin_connection
+ establish_vbulletin_connection
if Rails.version >= '3.2'
self.primary_key = :userid
@@ -15,7 +15,6 @@ class User < ActiveRecord::Base
set_table_name(PREFIX + 'user')
end
-
validates_presence_of :email, :password
validates_uniqueness_of :email
validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
@@ -23,9 +22,9 @@ class User < ActiveRecord::Base
has_one :userfield, :foreign_key => :userid, :dependent => :delete
has_one :usertextfield, :foreign_key => :userid, :dependent => :delete
has_many :session, :foreign_key => :userid, :dependent => :delete_all
-
+
after_initialize :defaults
-
+
# Sets all unnecessary parameters as default for newly registered VBulletin user.
def defaults
nowstamp = Time.now.to_i
@@ -50,7 +49,7 @@ def defaults
def authenticate(passwd)
User.password_hash(passwd.to_s, salt) == password ? self : false
end
-
+
# Authenticate VBulletin user with provided session hash. Returns VBulletinRails::User object if success
def authenticate_bb_password(bb_password_hash)
bb_password_hash == bb_password ? self : false
@@ -60,7 +59,7 @@ def authenticate_bb_password(bb_password_hash)
def bb_password
Digest::MD5.hexdigest(password + Rails.configuration.vbulletin.cookie_salt)
end
-
+
# Sets new VBulletinRails::User password
def password= passwd
return unless passwd
@@ -69,7 +68,7 @@ def password= passwd
self.salt = new_salt
self.send(:write_attribute, :password, User.password_hash(passwd.to_s, new_salt))
end
-
+
# Registers VBulletin user with given username/email and password
#
# VBulletinRails::User.register :username => 'username', :password => 'user password'
@@ -83,7 +82,7 @@ def self.register options
return vb_user
end
end
-
+
private
#:nodoc:
def self.password_hash password, salt
View
2  lib/vbulletin_rails/models/userfield.rb
@@ -1,7 +1,7 @@
module VBulletinRails
class Userfield < ActiveRecord::Base #:nodoc:
PREFIX = get_vbulletin_prefix
- establish_vbulletin_connection
+ establish_vbulletin_connection
if Rails.version >= '3.2'
self.primary_key = :userid
View
2  lib/vbulletin_rails/models/usertextfield.rb
@@ -1,7 +1,7 @@
module VBulletinRails
class Usertextfield < ActiveRecord::Base #:nodoc:
PREFIX = get_vbulletin_prefix
- establish_vbulletin_connection
+ establish_vbulletin_connection
if Rails.version >= '3.2'
self.primary_key = :userid
View
4 test/dummy/app/assets/stylesheets/application.css
@@ -3,5 +3,5 @@
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
- *= require_tree .
-*/
+ *= require_tree .
+*/
View
2  test/dummy/config/application.rb
@@ -39,7 +39,7 @@ class Application < Rails::Application #:nodoc:
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
-
+
# VBulletin COOKIE_SALT
config.vbulletin.cookie_salt = 'vBulletin cookie salt'
View
2  test/dummy/config/boot.rb
@@ -7,4 +7,4 @@
Bundler.setup
end
-$:.unshift File.expand_path('../../../../lib', __FILE__)
+$:.unshift File.expand_path('../../../../lib', __FILE__)
View
14 test/dummy/db/migrate/20111211115545_create_vbulletin_tables.rb
@@ -21,12 +21,12 @@ def self.up
t.string "apiaccesstoken", :limit => 32, :default => "", :null => false
t.integer "isbot", :limit => 1, :default => 0, :null => false
end
-
+
add_index "#{vb_prefix}session", ["apiaccesstoken"], :name => "apiaccesstoken"
add_index "#{vb_prefix}session", ["idhash", "host", "userid"], :name => "guest_lookup"
add_index "#{vb_prefix}session", ["lastactivity"], :name => "last_activity"
add_index "#{vb_prefix}session", ["userid", "lastactivity"], :name => "user_activity"
-
+
create_table "#{vb_prefix}user", :primary_key => "userid", :force => true do |t|
t.integer "usergroupid", :limit => 2, :default => 0, :null => false
t.string "membergroupids", :limit => 250, :default => "", :null => false
@@ -99,7 +99,7 @@ def self.up
t.string "logintype", :default => "vb", :null => false
t.string "fbaccesstoken", :default => "", :null => false
end
-
+
add_index "#{vb_prefix}user", ["birthday", "showbirthday"], :name => "birthday"
add_index "#{vb_prefix}user", ["birthday_search"], :name => "birthday_search"
add_index "#{vb_prefix}user", ["email"], :name => "email"
@@ -107,7 +107,7 @@ def self.up
add_index "#{vb_prefix}user", ["referrerid"], :name => "referrerid"
add_index "#{vb_prefix}user", ["usergroupid"], :name => "usergroupid"
add_index "#{vb_prefix}user", ["username"], :name => "username"
-
+
create_table "#{vb_prefix}userfield", :primary_key => "userid", :force => true do |t|
t.text "temp", :limit => 16777215
t.text "field1", :limit => 16777215
@@ -115,7 +115,7 @@ def self.up
t.text "field3", :limit => 16777215
t.text "field4", :limit => 16777215
end
-
+
create_table "#{vb_prefix}usertextfield", :primary_key => "userid", :force => true do |t|
t.text "subfolders", :limit => 16777215
t.text "pmfolders", :limit => 16777215
@@ -126,7 +126,7 @@ def self.up
t.text "rank", :limit => 16777215
end
end
-
+
def self.down
vb_prefix = ActiveRecord::Base.get_vbulletin_prefix
drop_table "#{vb_prefix}session"
@@ -134,5 +134,5 @@ def self.down
drop_table "#{vb_prefix}userfield"
drop_table "#{vb_prefix}usertextfield"
end
-
+
end
View
9 test/v_bulletin_rails_model_test.rb
@@ -23,7 +23,6 @@ def teardown
assert !@vbulletin.authenticate('wrongpassword')
end
-
test "it should check email validations" do
#check email
@@ -43,7 +42,7 @@ def teardown
assert_equal Date.parse('1800-01-01'), @vbulletin.birthday_search
assert @vbulletin.userid.to_i > 0
end
-
+
test "it should update user password" do
new_password = 'newpassword'
@vbulletin.password = new_password
@@ -93,7 +92,7 @@ def teardown
get_session = VBulletinRails::Session.get(:sessionhash => vb_session.sessionhash, :request => request)
assert_instance_of VBulletinRails::Session, get_session
end
-
+
vb_session = VBulletinRails::Session.set(:request => request, :email => 'vb2@example.com', :username => 'vb2', :user => @vbulletin)
get_session = VBulletinRails::Session.get(:sessionhash => vb_session.sessionhash, :request => request)
assert_instance_of VBulletinRails::Session, get_session
@@ -112,7 +111,7 @@ def teardown
assert_nil VBulletinRails::Session.destroy('wrongsessionid')
assert_instance_of VBulletinRails::Session, VBulletinRails::Session.destroy(vb_session.sessionhash)
assert_nil VBulletinRails::Session.find_by_sessionhash(vb_session.sessionhash)
-
+
vb_session = VBulletinRails::Session.set(:request => request, :user => @vbulletin)
vb_session_user_before_update = vb_session.user.dup
vb_session_after_update = vb_session.update_timestamps
@@ -123,7 +122,7 @@ def teardown
vb_session_user_before_update = vb_session.user.reload.dup
assert_equal [vb_session.lastactivity, vb_session_user_before_update.lastactivity], vb_session.update_timestamps
assert_equal vb_session.lastactivity, vb_session.user.lastactivity
- assert_equal vb_session_user_before_update.lastactivity, vb_session.user.lastvisit
+ assert_equal vb_session_user_before_update.lastactivity, vb_session.user.lastvisit
end
end
View
2  test/v_bulletin_rails_test.rb
@@ -48,7 +48,7 @@ def setup
test 'alt_ip retriever' do
headers = {'REMOTE_ADDR' => '199.99.99.99'}
assert_equal headers['REMOTE_ADDR'], VBulletinRails::fetch_alt_ip(headers)
-
+
headers['HTTP_X_REAL_IP'] = '199.99.99.9'
assert_equal headers['HTTP_X_REAL_IP'], VBulletinRails::fetch_alt_ip(headers)
Please sign in to comment.
Something went wrong with that request. Please try again.