Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upgrade to rails 3.2 and rspec 2.8. Drop Rails 2.x support.

  • Loading branch information...
commit 61c74a867822300de464ac378c4163a976a912ee 1 parent baa2640
@kommen kommen authored
View
10 Gemfile
@@ -1,9 +1,9 @@
source "http://rubygems.org"
-gem 'rails', '~> 2.3.0'
-gem 'activerecord', '~> 2.3.0', :require => 'active_record'
-gem 'activesupport', '~> 2.3.0', :require => 'active_support'
-gem 'actionpack', '~> 2.3.0', :require => 'action_pack'
+gem 'rails', '~> 3.2.0'
+gem 'activerecord', '~> 3.2.0', :require => 'active_record'
+gem 'activesupport', '~> 3.2.0', :require => 'active_support'
+gem 'actionpack', '~> 3.2.0', :require => 'action_pack'
gem 'sqlite3-ruby', '>= 1.2.0'
gem 'mysql', '>= 2.8.0'
@@ -11,7 +11,7 @@ gem 'pg', '>= 0.9.0'
gem 'tzinfo', '>= 0.3.0'
gem 'rake', '>= 0.8.7'
-gem 'rspec', '~> 1.3.0'
+gem 'rspec', '~> 2.8.0'
gem 'simplecov'
gem 'excellent', '>= 1.5.4'
gem 'yard', '>= 0.4.0'
View
6 Rakefile
@@ -12,9 +12,9 @@ task :default => :spec
desc 'Run the specs'
Spec::Rake::SpecTask.new(:spec) do |t|
- t.rcov_opts << '--exclude "gems/*,spec/*,init.rb"'
- t.rcov = true
- t.rcov_dir = 'doc/coverage'
+ # t.rcov_opts << '--exclude "gems/*,spec/*,init.rb"'
+ # t.rcov = true
+ # t.rcov_dir = 'doc/coverage'
t.spec_files = FileList['spec/**/*_spec.rb']
end
View
6 lib/saulabs/reportable.rb
@@ -1,5 +1,7 @@
+
require 'saulabs/reportable/report'
require 'saulabs/reportable/cumulated_report'
+require 'saulabs/reportable/railtie'
module Saulabs
@@ -9,10 +11,6 @@ module Reportable
#
module RailsAdapter
- IS_RAILS3 = defined?(Rails) && Rails::VERSION::MAJOR >= 3
-
- require 'saulabs/reportable/railtie' if IS_RAILS3
-
# Extends the {Saulabs::Reportable::ClassMethods#reportable} method into +base+.
#
def self.included(base)
View
12 lib/saulabs/reportable/railtie.rb
@@ -10,7 +10,17 @@ class Railtie < Rails::Railtie
GEM_ROOT = File.join(File.dirname(__FILE__), '..', '..', '..')
initializer 'saulabs.reportable.initialization' do
- require File.join(GEM_ROOT, 'rails', 'init')
+ ActiveSupport.on_load :active_record do
+ ActiveRecord::Base.class_eval do
+ include Saulabs::Reportable::RailsAdapter
+ end
+ end
+ ActiveSupport.on_load :action_view do
+ ActionView::Base.class_eval do
+ include Saulabs::Reportable::ReportTagHelper
+ end
+ end
+
end
generators do
View
1  lib/saulabs/reportable/report_cache.rb
@@ -1,5 +1,6 @@
require 'saulabs/reportable/reporting_period'
require 'saulabs/reportable/result_set'
+require 'active_record'
module Saulabs
View
11 rails/init.rb
@@ -1,11 +0,0 @@
-require 'action_view'
-require 'saulabs/reportable'
-require 'saulabs/reportable/report_tag_helper'
-
-ActiveRecord::Base.class_eval do
- include Saulabs::Reportable::RailsAdapter
-end
-
-ActionView::Base.class_eval do
- include Saulabs::Reportable::ReportTagHelper
-end
View
22 spec/boot.rb
@@ -1,22 +0,0 @@
-plugin_root = File.join(File.dirname(__FILE__), '..')
-
-$:.unshift "#{plugin_root}/lib"
-
-Bundler.require
-require 'initializer'
-
-RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + '/../') unless defined?(RAILS_ROOT)
-Rails::Initializer.run(:set_load_path)
-Rails::Initializer.run(:set_autoload_paths)
-Rails::Initializer.run(:initialize_time_zone) do |config|
- config.time_zone = 'Pacific Time (US & Canada)'
-end
-
-require File.join(File.dirname(__FILE__), '..', 'rails', 'init.rb')
-
-FileUtils.mkdir_p File.join(File.dirname(__FILE__), 'log')
-ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), 'log', 'spec.log'))
-
-databases = YAML::load(IO.read(File.join(File.dirname(__FILE__), 'db', 'database.yml')))
-ActiveRecord::Base.establish_connection(databases[ENV['DB'] || 'sqlite3'])
-load(File.join(File.dirname(__FILE__), 'db', 'schema.rb'))
View
17 spec/other/report_method_spec.rb
@@ -1,7 +1,17 @@
require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))),'spec_helper')
describe Saulabs::Reportable do
+
+ ActiveRecord::Base.class_eval do
+ include Saulabs::Reportable::RailsAdapter
+ end
+
+ class User < ActiveRecord::Base
+ reportable :registrations, :limit => 10
+ end
+ class SpecialUser < User; end
+
before(:all) do
User.create!(:login => 'test 1', :created_at => Time.now - 1.days, :profile_visits => 1)
User.create!(:login => 'test 2', :created_at => Time.now - 2.days, :profile_visits => 2)
@@ -59,10 +69,3 @@
end
-class User < ActiveRecord::Base
-
- reportable :registrations, :limit => 10
-
-end
-
-class SpecialUser < User; end
View
2  spec/other/report_tag_helper_spec.rb
@@ -1,5 +1,7 @@
require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))),'spec_helper')
+require 'reportable/report_tag_helper'
+
describe Saulabs::Reportable::ReportTagHelper do
before do
View
42 spec/spec_helper.rb
@@ -1,19 +1,39 @@
ENV['RAILS_ENV'] = 'test'
require 'rubygems'
-require 'bundler'
-Bundler.setup
-
-require File.join(File.dirname(__FILE__), 'boot')
-
-class User < ActiveRecord::Base; end
-
-class YieldMatchException < Exception; end
+require 'bundler/setup'
+require 'active_record'
+require 'active_record/version'
+require 'active_support'
begin
require 'ruby-debug'
- Debugger.start
- Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings)
+ # Debugger.start
+ # Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings)
rescue LoadError
# ruby-debug wasn't available so neither can the debugging be
-end
+end
+
+ROOT = Pathname(File.expand_path(File.join(File.dirname(__FILE__), '..')))
+
+$LOAD_PATH << File.join(ROOT, 'lib')
+$LOAD_PATH << File.join(ROOT, 'lib/saulabs')
+
+require File.join(ROOT, 'lib', 'saulabs', 'reportable.rb')
+
+# Rails::Initializer.run(:set_load_path)
+# Rails::Initializer.run(:set_autoload_paths)
+# Rails::Initializer.run(:initialize_time_zone) do |config|
+# config.time_zone = 'Pacific Time (US & Canada)'
+# end
+
+FileUtils.mkdir_p File.join(File.dirname(__FILE__), 'log')
+ActiveRecord::Base.logger = ActiveSupport::BufferedLogger.new(File.dirname(__FILE__) + "/log/spec.log")
+
+databases = YAML::load(IO.read(File.join(File.dirname(__FILE__), 'db', 'database.yml')))
+ActiveRecord::Base.establish_connection(databases[ENV['DB'] || 'sqlite3'])
+load(File.join(File.dirname(__FILE__), 'db', 'schema.rb'))
+
+class User < ActiveRecord::Base; end
+
+class YieldMatchException < Exception; end
Please sign in to comment.
Something went wrong with that request. Please try again.