diff --git a/Gemfile b/Gemfile
index dba94f5..5fb098f 100644
--- a/Gemfile
+++ b/Gemfile
@@ -46,6 +46,7 @@ group :test do
gem 'rspec', '~> 2.14.0'
gem 'rspec-rails', '~> 2.14.1'
gem 'mocha', '~> 1.1.0', :require => false
+ gem 'spring'
gem 'test-unit' if RUBY_VERSION >= '2.2.0'
gem 'minitest'
gem 'minitest-reporters'
diff --git a/app/helpers/folder_helper.rb b/app/helpers/folder_helper.rb
index a1b43d0..bbe9b4e 100644
--- a/app/helpers/folder_helper.rb
+++ b/app/helpers/folder_helper.rb
@@ -6,8 +6,7 @@ module FolderHelper
configure[:recursive] ||= false
configure[:list_type] ||= :folder
if !configure[:contents].blank?
- configure[:contents] = configure[:contents].paginate(
- :order => "name ASC",
+ configure[:contents] = configure[:contents].order('name ASC').paginate(
:per_page => 30,
:page => params[:npage]
)
diff --git a/app/models/add_member.rb b/app/models/add_member.rb
index bd20dfb..be454d7 100644
--- a/app/models/add_member.rb
+++ b/app/models/add_member.rb
@@ -8,7 +8,7 @@ class AddMember < Task
alias :organization :target
alias :organization= :target=
- settings_items :roles
+ settings_items :roles, type: Array
after_create do |task|
remove_from_suggestion_list(task)
diff --git a/app/models/blog_archives_block.rb b/app/models/blog_archives_block.rb
index 30687af..d36ddad 100644
--- a/app/models/blog_archives_block.rb
+++ b/app/models/blog_archives_block.rb
@@ -33,10 +33,10 @@ class BlogArchivesBlock < Block
results = ''
posts = visible_posts(args[:person])
posts.except(:order).count(:all, :group => 'EXTRACT(YEAR FROM published_at)').sort_by {|year, count| -year.to_i}.each do |year, count|
- results << content_tag('li', content_tag('strong', "#{year} (#{count})"))
- results << "
"
- posts.except(:order).where('EXTRACT(YEAR FROM published_at)=?', year).group('EXTRACT(MONTH FROM published_at)').count.sort_by {|month, count| -month.to_i}.each do |month, count|
- results << content_tag('li', link_to("#{month_name(month.to_i)} (#{count})", owner_blog.url.merge(:year => year, :month => month)))
+ results << content_tag('li', content_tag('strong', "#{year.to_i} (#{count})"))
+ results << ""
+ posts.except(:order).where('EXTRACT(YEAR FROM published_at)=?', year.to_i).group('EXTRACT(MONTH FROM published_at)').count.sort_by {|month, count| -month.to_i}.each do |month, count|
+ results << content_tag('li', link_to("#{month_name(month.to_i)} (#{count})", owner_blog.url.merge(year: year.to_i, month: month.to_i)))
end
results << "
"
end
diff --git a/app/models/category.rb b/app/models/category.rb
index f5ca326..a726fdc 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -53,19 +53,19 @@ class Category < ActiveRecord::Base
}
def recent_people(limit = 10)
- self.people.paginate(:order => 'created_at DESC, id DESC', :page => 1, :per_page => limit)
+ self.people.reorder('created_at DESC, id DESC').paginate(page: 1, per_page: limit)
end
def recent_enterprises(limit = 10)
- self.enterprises.paginate(:order => 'created_at DESC, id DESC', :page => 1, :per_page => limit)
+ self.enterprises.reorder('created_at DESC, id DESC').paginate(page: 1, per_page: limit)
end
def recent_communities(limit = 10)
- self.communities.paginate(:order => 'created_at DESC, id DESC', :page => 1, :per_page => limit)
+ self.communities.reorder('created_at DESC, id DESC').paginate(page: 1, per_page: limit)
end
def recent_products(limit = 10)
- self.products.paginate(:order => 'created_at DESC, id DESC', :page => 1, :per_page => limit)
+ self.products.reorder('created_at DESC, id DESC').paginate(page: 1, per_page: limit)
end
def recent_articles(limit = 10)
@@ -73,7 +73,7 @@ class Category < ActiveRecord::Base
end
def recent_comments(limit = 10)
- comments.paginate(:order => 'created_at DESC, comments.id DESC', :page => 1, :per_page => limit)
+ self.comments.reorder('created_at DESC, comments.id DESC').paginate(page: 1, per_page: limit)
end
def most_commented_articles(limit = 10)
@@ -81,7 +81,7 @@ class Category < ActiveRecord::Base
end
def upcoming_events(limit = 10)
- self.events.where('start_date >= ?', Date.today).order('start_date').paginate(:page => 1, :per_page => limit)
+ self.events.where('start_date >= ?', Date.today).reorder('start_date').paginate(:page => 1, :per_page => limit)
end
def display_in_menu?
@@ -90,8 +90,8 @@ class Category < ActiveRecord::Base
def children_for_menu
results = []
- pending = children.where :display_in_menu => true
- while !pending.empty?
+ pending = children.where(display_in_menu: true).all
+ while pending.present?
cat = pending.shift
results << cat
pending += cat.children.where :display_in_menu => true
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 3eee221..10d5c68 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -942,7 +942,7 @@ class Environment < ActiveRecord::Base
end
def highlighted_products_with_image(options = {})
- Product.where(highlighted: true, profile_id: self.enterprises.where(select: :id)).joins(:image)
+ self.products.where(highlighted: true).joins(:image)
end
settings_items :home_cache_in_minutes, :type => :integer, :default => 5
diff --git a/app/models/event.rb b/app/models/event.rb
index c834067..4a46453 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -12,14 +12,14 @@ class Event < Article
settings_items :address, :type => :string
def link=(value)
- self.setting[:link] = maybe_add_http(value)
+ self.setting[:link] = maybe_add_http(URI.escape value.to_s)
end
def link
maybe_add_http(self.setting[:link])
end
- xss_terminate :only => [ :name, :body, :link, :address ], :with => 'white_list', :on => 'validation'
+ xss_terminate :only => [ :name, :body, :address ], :with => 'white_list', :on => 'validation'
def initialize(*args)
super(*args)
diff --git a/app/models/featured_products_block.rb b/app/models/featured_products_block.rb
index 426cf3c..5d4f554 100644
--- a/app/models/featured_products_block.rb
+++ b/app/models/featured_products_block.rb
@@ -11,7 +11,7 @@ class FeaturedProductsBlock < Block
if block.owner.kind_of?(Environment) && block.product_ids.blank?
total = block.owner.products.count
offset = rand([(total - block.groups_of * 3) + 1, 1].max)
- block.product_ids = block.owner.highlighted_products_with_image(:offset => offset, :limit => block.groups_of * 3).map(&:id)
+ block.product_ids = block.owner.highlighted_products_with_image.offset(offset).limit(block.groups_of * 3).map(&:id)
end
block.groups_of = block.groups_of.to_i
end
diff --git a/app/models/profile_suggestion.rb b/app/models/profile_suggestion.rb
index cf58b30..e60a608 100644
--- a/app/models/profile_suggestion.rb
+++ b/app/models/profile_suggestion.rb
@@ -136,7 +136,7 @@ class ProfileSuggestion < ActiveRecord::Base
suggestion.send("#{rule}=", value)
connections.each do |connection_id|
next if SuggestionConnection.where(:suggestion_id => suggestion.id, :connection_id => connection_id, :connection_type => options[:connection]).present?
- SuggestionConnection.create!(:suggestion => suggestion, :connection_id => connection_id, :connection_type => options[:connection])
+ SuggestionConnection.create!(:suggestion => suggestion, :connection_id => connection_id, :connection_type => options[:connection])
end
suggestion.score += value * options[:weight]
end
diff --git a/app/models/suggestion_connection.rb b/app/models/suggestion_connection.rb
index fac6898..93f17c2 100644
--- a/app/models/suggestion_connection.rb
+++ b/app/models/suggestion_connection.rb
@@ -1,5 +1,5 @@
class SuggestionConnection < ActiveRecord::Base
- attr_accessible :suggestion, :connection_type, :connection_id
+ attr_accessible :suggestion, :suggestion_id, :connection_type, :connection_id
belongs_to :suggestion, :class_name => 'ProfileSuggestion', :foreign_key => 'suggestion_id'
belongs_to :connection, :polymorphic => true
diff --git a/config/initializers/dependencies.rb b/config/initializers/dependencies.rb
index 2c9f99c..83f4c31 100644
--- a/config/initializers/dependencies.rb
+++ b/config/initializers/dependencies.rb
@@ -1,3 +1,5 @@
+require 'pp'
+
# third-party libraries
require 'will_paginate'
require 'will_paginate/array'
diff --git a/lib/acts_as_having_settings.rb b/lib/acts_as_having_settings.rb
index e454bcb..20fc92e 100644
--- a/lib/acts_as_having_settings.rb
+++ b/lib/acts_as_having_settings.rb
@@ -8,12 +8,12 @@ module ActiveRecord
end
class Array < Value
def cast_value value
- Array(value)
+ ::Array.wrap(value)
end
end
class Hash < Value
def cast_value value
- Hash[value]
+ ::Hash[value]
end
end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 1e4ac39..7f00b13 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -139,18 +139,16 @@ class ActiveSupport::TestCase
assert !text.index('<'), "Text '#{text}' expected to be sanitized"
end
- def find_tag_in_string text, options
- doc = Nokogiri::HTML.fragment text
- tag = doc.css("#{options[:tag]}#{options[:attributes].map{ |a, v| "[#{a}=\"#{v}\"]" }.join}").first
- tag
- end
-
def assert_tag_in_string(text, options)
- assert find_tag_in_string(text, options), "expected tag #{options.inspect}, but not found in #{text.inspect}"
+ doc = HTML::Document.new(text, false, false)
+ tag = doc.find(options)
+ assert tag, "expected tag #{options.inspect}, but not found in #{text.inspect}"
end
def assert_no_tag_in_string(text, options)
- assert !find_tag_in_string(text, options), "expected no tag #{options.inspect}, but tag found in #{text.inspect}"
+ doc = HTML::Document.new(text, false, false)
+ tag = doc.find(options)
+ assert !tag, "expected no tag #{options.inspect}, but tag found in #{text.inspect}"
end
def assert_order(reference, original)
diff --git a/test/unit/catalog_helper_test.rb b/test/unit/catalog_helper_test.rb
index a828824..6aef0a8 100644
--- a/test/unit/catalog_helper_test.rb
+++ b/test/unit/catalog_helper_test.rb
@@ -6,7 +6,12 @@ class CatalogHelperTest < ActiveSupport::TestCase
include ActionView::Helpers::TextHelper
include ActionView::Helpers::UrlHelper
include ActionView::Helpers::TagHelper
+
include ::Rails::Dom::Testing::Assertions::SelectorAssertions
+ # see http://blog.cynthiakiser.com/blog/2014/12/26/upgrading-from-rails-4-dot-1-8-to-4-dot-2-0/
+ def document_root_element
+ @doc.root
+ end
def url_for(opts)
#{:controller => 'catalog', :action => 'index', :level => category.id}
@@ -44,7 +49,7 @@ class CatalogHelperTest < ActiveSupport::TestCase
html = category_with_sub_list @products
- doc = HTML::Document.new "#{html}"
+ @doc = doc = HTML::Document.new "#{html}"
assert_select doc.root, 'div' do |divs|
assert_select divs[0], "a[href=catalog-index-level=#{@products.id}]"
assert_select divs[0], '.count', {:text=>'3'}
diff --git a/test/unit/change_password_test.rb b/test/unit/change_password_test.rb
index 6e8ce9e..6421cb5 100644
--- a/test/unit/change_password_test.rb
+++ b/test/unit/change_password_test.rb
@@ -17,8 +17,7 @@ class ChangePasswordTest < ActiveSupport::TestCase
change.password = 'right'
change.password_confirmation = 'wrong'
assert !change.valid?
- assert change.errors[:password.to_s].present?
-
+ assert change.errors[:password_confirmation].present?
change.password_confirmation = 'right'
assert change.valid?
diff --git a/test/unit/event_test.rb b/test/unit/event_test.rb
index d4559a5..e82ad56 100644
--- a/test/unit/event_test.rb
+++ b/test/unit/event_test.rb
@@ -285,11 +285,11 @@ class EventTest < ActiveSupport::TestCase
should 'filter fields with white_list filter' do
event = Event.new
event.body = " Description
"
- event.address = " Address "
+ event.address = " Address "
event.valid?
assert_equal " Description
", event.body
- assert_equal " Address ", event.address
+ assert_equal " Address ", event.address
end
should 'not filter & on link field' do
@@ -306,8 +306,8 @@ class EventTest < ActiveSupport::TestCase
event.address = "><< Address "
event.valid?
- assert_no_match /[<>]/, event.body
- assert_no_match /[<>]/, event.address
+ assert_match />\/h1><\/h1>/, event.body
+ assert_match /><\/strong>/, event.address
end
should 'not sanitize html comments' do
@@ -316,8 +316,8 @@ class EventTest < ActiveSupport::TestCase
event.address = '
Wellformed html code
'
event.valid?
- assert_match / Wellformed html code <\/h1>/, event.body
- assert_match / Wellformed html code <\/h1>/, event.address
+ assert_match /
<\/p>
Wellformed html code <\/h1>/, event.body
+ assert_match /
<\/p>
Wellformed html code <\/h1>/, event.address
end
should 'be translatable' do
diff --git a/test/unit/folder_test.rb b/test/unit/folder_test.rb
index e2a0a51..734a7f5 100644
--- a/test/unit/folder_test.rb
+++ b/test/unit/folder_test.rb
@@ -129,7 +129,7 @@ class FolderTest < ActiveSupport::TestCase
folder.body = '
Wellformed html code
'
folder.valid?
- assert_match / Wellformed html code <\/h1>/, folder.body
+ assert_match /
<\/p>
Wellformed html code <\/h1>/, folder.body
end
should 'escape malformed html tags' do
@@ -137,7 +137,7 @@ class FolderTest < ActiveSupport::TestCase
folder.body = ">/h1>"
folder.valid?
- assert_no_match /[<>]/, folder.body
+ assert_match />\/h1><\/h1>/, folder.body
end
should 'not have a blog as parent' do
diff --git a/test/unit/gallery_test.rb b/test/unit/gallery_test.rb
index 928f550..b363788 100644
--- a/test/unit/gallery_test.rb
+++ b/test/unit/gallery_test.rb
@@ -130,7 +130,7 @@ class GalleryTest < ActiveSupport::TestCase
gallery.body = '
Wellformed html code
'
gallery.valid?
- assert_match / Wellformed html code <\/h1>/, gallery.body
+ assert_match /
<\/p>
Wellformed html code <\/h1>/, gallery.body
end
should 'escape malformed html tags' do
@@ -138,7 +138,7 @@ class GalleryTest < ActiveSupport::TestCase
gallery.body = ">/h1>"
gallery.valid?
- assert_no_match /[<>]/, gallery.body
+ assert_match />\/h1><\/h1>/, gallery.body
end
should 'accept uploads' do
diff --git a/test/unit/macros_helper_test.rb b/test/unit/macros_helper_test.rb
index 926ed69..476d67b 100644
--- a/test/unit/macros_helper_test.rb
+++ b/test/unit/macros_helper_test.rb
@@ -102,8 +102,7 @@ class MacrosHelperTest < ActionView::TestCase
{:js_files => 'macro.js' }
end
end
- ActionView::Helpers::AssetTagHelper::JavascriptIncludeTag.any_instance.stubs('asset_file_path!')
- assert_equal "", include_macro_js_files
+ assert_equal "", include_macro_js_files
end
should 'get macro css files' do
diff --git a/test/unit/profile_suggestion_test.rb b/test/unit/profile_suggestion_test.rb
index 74a673c..8412882 100644
--- a/test/unit/profile_suggestion_test.rb
+++ b/test/unit/profile_suggestion_test.rb
@@ -1,5 +1,5 @@
# encoding: UTF-8
-require File.dirname(__FILE__) + '/../test_helper'
+require 'test_helper'
class ProfileSuggestionTest < ActiveSupport::TestCase
diff --git a/vendor/plugins/kandadaboggu-vote_fu/lib/acts_as_voteable.rb b/vendor/plugins/kandadaboggu-vote_fu/lib/acts_as_voteable.rb
index 30415ea..26cdcce 100644
--- a/vendor/plugins/kandadaboggu-vote_fu/lib/acts_as_voteable.rb
+++ b/vendor/plugins/kandadaboggu-vote_fu/lib/acts_as_voteable.rb
@@ -8,13 +8,13 @@ module Juixe
end
module ClassMethods
- #
+ #
# Options:
- # :vote_counter
+ # :vote_counter
# Model stores the sum of votes in the vote counter column when the value is true. This requires a column named `vote_total` in the table corresponding to `voteable` model.
- # You can also specify a custom vote counter column by providing a column name instead of a true/false value to this option (e.g., :vote_counter => :my_custom_counter.)
+ # You can also specify a custom vote counter column by providing a column name instead of a true/false value to this option (e.g., :vote_counter => :my_custom_counter.)
# Note: Specifying a counter will add it to that model‘s list of readonly attributes using attr_readonly.
- #
+ #
def acts_as_voteable options={}
has_many :votes, :as => :voteable, :dependent => :destroy
include Juixe::Acts::Voteable::InstanceMethods
@@ -28,15 +28,15 @@ module Juixe
def self.vote_counter_column # def self.vote_counter_column
:"#{counter_column_name}" # :vote_total
end # end
- def vote_counter_column
- self.class.vote_counter_column
- end
+ def vote_counter_column
+ self.class.vote_counter_column
+ end
EOS
-
+
define_method(:reload_vote_counter) {reload(:select => vote_counter_column.to_s)}
attr_readonly counter_column_name
end
- end
+ end
end
# This module contains class methods Vote class
@@ -49,13 +49,13 @@ module Juixe
def update_vote_counters direction
klass, vtbl = self.voteable.class, self.voteable
- klass.update_counters(vtbl.id, vtbl.vote_counter_column.to_sym => (self.vote * direction) ) if self.vote_counters.any?{|c| c == klass}
+ klass.update_counters(vtbl.id, vtbl.vote_counter_column.to_sym => (self.vote * direction) ) if self.vote_counters.any?{|c| c == klass}
end
end
-
+
# This module contains class methods
module SingletonMethods
-
+
# Calculate the vote counts for all voteables of my type.
# Options:
# :start_at - Restrict the votes to those created after a certain time
@@ -63,7 +63,7 @@ module Juixe
# :conditions - A piece of SQL conditions to add to the query
# :limit - The maximum number of voteables to return
# :order - A piece of SQL to order by. Two calculated columns `count`, and `total`
- # are available for sorting apart from other columns. Defaults to `total DESC`.
+ # are available for sorting apart from other columns. Defaults to `total DESC`.
# Eg: :order => 'count desc'
# :order => 'total desc'
# :order => 'post.created_at desc'
@@ -76,7 +76,7 @@ module Juixe
end
def options_for_tally (options = {})
- options.assert_valid_keys :start_at, :end_at, :conditions, :at_least, :at_most, :order, :limit, :at_least_total, :at_most_total
+ options.assert_valid_keys :start_at, :end_at, :conditions, :at_least, :at_most, :order, :limit, :at_least_total, :at_most_total
scope = scope(:find)
start_at = sanitize_sql(["#{Vote.table_name}.created_at >= ?", options.delete(:start_at)]) if options[:start_at]
@@ -85,7 +85,7 @@ module Juixe
if respond_to?(:vote_counter_column)
# use the counter cache column if present.
total_col = "#{table_name}.#{vote_counter_column}"
- at_least_total = sanitize_sql(["#{total_col} >= ?", options.delete(:at_least_total)]) if options[:at_least_total]
+ at_least_total = sanitize_sql(["#{total_col} >= ?", options.delete(:at_least_total)]) if options[:at_least_total]
at_most_total = sanitize_sql(["#{total_col} <= ?", options.delete(:at_most_total)]) if options[:at_most_total]
end
conditions = [
@@ -104,7 +104,7 @@ module Juixe
joins << scope[:joins] if scope && scope[:joins]
at_least = sanitize_sql(["COUNT(#{Vote.table_name}.id) >= ?", options.delete(:at_least)]) if options[:at_least]
at_most = sanitize_sql(["COUNT(#{Vote.table_name}.id) <= ?", options.delete(:at_most)]) if options[:at_most]
- at_least_total = at_most_total = nil # reset the values
+ at_least_total = at_most_total = nil # reset the values
unless respond_to?(:vote_counter_column)
# aggregate the votes when counter cache is absent.
total_col = "SUM(#{Vote.table_name}.vote)"
@@ -114,26 +114,26 @@ module Juixe
having = [at_least, at_most, at_least_total, at_most_total].compact.join(' AND ')
group_by = "#{Vote.table_name}.voteable_id HAVING COUNT(#{Vote.table_name}.id) > 0"
group_by << " AND #{having}" unless having.blank?
-
- { :select => "#{table_name}.*, COUNT(#{Vote.table_name}.id) AS count, #{total_col} AS total",
+
+ { :select => "#{table_name}.*, COUNT(#{Vote.table_name}.id) AS count, #{total_col} AS total",
:joins => joins.join(" "),
:conditions => conditions,
:group => group_by
- }.update(options)
+ }.update(options)
end
-
+
end
-
+
# This module contains instance methods
module InstanceMethods
def votes_for
- self.votes.count(:conditions => {:vote => 1})
+ self.votes.where(vote: 1).count
end
-
+
def votes_against
- self.votes.count(:conditions => {:vote => -1})
+ self.votes.where(vote: -1).count
end
-
+
# Same as voteable.votes.size
def votes_count
self.votes.size
@@ -142,11 +142,11 @@ module Juixe
def votes_total
respond_to?(:vote_counter_column) ? send(self.vote_counter_column) : self.votes.sum(:vote)
end
-
+
def voters_who_voted
self.votes.collect(&:voter)
end
-
+
def voted_by?(voter, for_or_against = "all")
options = (for_or_against == "all") ? {} : {:vote => (for_or_against ? 1 : -1)}
self.votes.exists?({:voter_id => voter.id, :voter_type => voter.class.base_class.name}.merge(options))
diff --git a/vendor/plugins/kandadaboggu-vote_fu/lib/acts_as_voter.rb b/vendor/plugins/kandadaboggu-vote_fu/lib/acts_as_voter.rb
index 2844d4c..802fac4 100644
--- a/vendor/plugins/kandadaboggu-vote_fu/lib/acts_as_voter.rb
+++ b/vendor/plugins/kandadaboggu-vote_fu/lib/acts_as_voter.rb
@@ -9,28 +9,28 @@ module PeteOnRails
module ClassMethods
def acts_as_voter
- has_many :votes, :as => :voter, :dependent => :nullify # If a voting entity is deleted, keep the votes.
+ has_many :votes, :as => :voter, :dependent => :nullify # If a voting entity is deleted, keep the votes.
include PeteOnRails::Acts::Voter::InstanceMethods
extend PeteOnRails::Acts::Voter::SingletonMethods
end
end
-
+
# This module contains class methods
module SingletonMethods
end
-
+
# This module contains instance methods
module InstanceMethods
-
+
# Usage user.vote_count(true) # All +1 votes
# user.vote_count(false) # All -1 votes
# user.vote_count() # All votes
#
def vote_count(for_or_against = "all")
return self.votes.size if for_or_against == "all"
- self.votes.count(:conditions => {:vote => (for_or_against ? 1 : -1)})
+ self.votes.where(vote: if for_or_against then 1 else -1 end).count
end
-
+
def voted_for?(voteable)
voteable.voted_by?(self, true)
end
@@ -42,11 +42,11 @@ module PeteOnRails
def voted_on?(voteable)
voteable.voted_by?(self)
end
-
+
def vote_for(voteable)
self.vote(voteable, 1)
end
-
+
def vote_against(voteable)
self.vote(voteable, -1)
end
@@ -56,10 +56,10 @@ module PeteOnRails
voteable.reload_vote_counter if !v.new_record? and voteable.respond_to?(:reload_vote_counter)
end.errors.empty?
end
-
+
end
-
+
end
-
+
end
-end
\ No newline at end of file
+end
diff --git a/vendor/plugins/kandadaboggu-vote_fu/lib/models/vote.rb b/vendor/plugins/kandadaboggu-vote_fu/lib/models/vote.rb
index b303dec..40eb637 100644
--- a/vendor/plugins/kandadaboggu-vote_fu/lib/models/vote.rb
+++ b/vendor/plugins/kandadaboggu-vote_fu/lib/models/vote.rb
@@ -1,17 +1,23 @@
class Vote < ActiveRecord::Base
- scope :for_voter, lambda { |*args| {:conditions => ["voter_id = ? AND voter_type = ?", args.first.id, args.first.class.base_class.name]} }
- scope :for_voteable, lambda { |*args| {:conditions => ["voteable_id = ? AND voteable_type = ?", args.first.id, args.first.class.base_class.name]} }
- scope :recent, lambda { |*args| {:conditions => ["created_at > ?", (args.first || 2.weeks.ago).to_s(:db)]} }
- scope :descending, :order => "created_at DESC"
+ scope :for_voter, -> (*args) {
+ where "voter_id = ? AND voter_type = ?", args.first.id, args.first.class.base_class.name
+ }
+ scope :for_voteable, -> (*args) {
+ where "voteable_id = ? AND voteable_type = ?", args.first.id, args.first.class.base_class.name
+ }
+ scope :recent, -> (*args) {
+ where "created_at > ?", (args.first || 2.weeks.ago).to_s(:db)
+ }
+ scope :descending, -> { order "created_at DESC" }
# NOTE: Votes belong to the "voteable" interface, and also to voters
belongs_to :voteable, :polymorphic => true
belongs_to :voter, :polymorphic => true
-
+
attr_accessible :vote, :voter, :voteable
- # Uncomment this to limit users to a single vote on each item.
+ # Uncomment this to limit users to a single vote on each item.
#validates_uniqueness_of :voteable_id, :scope => [:voteable_type, :voter_type, :voter_id]
end
--
libgit2 0.21.2