diff --git a/spec/models/cost_query/chaining_spec.rb b/spec/models/cost_query/chaining_spec.rb index f917087b80..beb3e7f0a3 100644 --- a/spec/models/cost_query/chaining_spec.rb +++ b/spec/models/cost_query/chaining_spec.rb @@ -1,6 +1,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +require_relative 'query_helper' -describe CostQuery do +describe CostQuery, :reporting_query_helper => true do minimal_query fixtures :users diff --git a/spec/models/cost_query/filter_spec.rb b/spec/models/cost_query/filter_spec.rb index 57bcdfaff8..50896e7025 100644 --- a/spec/models/cost_query/filter_spec.rb +++ b/spec/models/cost_query/filter_spec.rb @@ -1,6 +1,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +require_relative 'query_helper' -describe CostQuery do +describe CostQuery, :reporting_query_helper => true do minimal_query fixtures :users diff --git a/spec/models/cost_query/group_by_spec.rb b/spec/models/cost_query/group_by_spec.rb index 4cde93f0a0..f0dbdcefe5 100644 --- a/spec/models/cost_query/group_by_spec.rb +++ b/spec/models/cost_query/group_by_spec.rb @@ -1,6 +1,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +require_relative 'query_helper' -describe CostQuery do +describe CostQuery, :reporting_query_helper do minimal_query fixtures :users diff --git a/spec/models/cost_query/integration_spec.rb b/spec/models/cost_query/integration_spec.rb index fe6dc4f7f1..27b517ba7b 100644 --- a/spec/models/cost_query/integration_spec.rb +++ b/spec/models/cost_query/integration_spec.rb @@ -1,6 +1,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +require_relative 'query_helper' -describe CostQuery do +describe CostQuery, :reporting_query_helper => true do minimal_query fixtures :users diff --git a/spec/models/cost_query/operator_spec.rb b/spec/models/cost_query/operator_spec.rb index 8629ea38d3..954e188041 100644 --- a/spec/models/cost_query/operator_spec.rb +++ b/spec/models/cost_query/operator_spec.rb @@ -1,6 +1,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +require_relative 'query_helper' -describe CostQuery do +describe CostQuery, :reporting_query_helper => true do minimal_query fixtures :users diff --git a/spec/models/cost_query/query_helper.rb b/spec/models/cost_query/query_helper.rb index f75654e801..cd2b0202ba 100644 --- a/spec/models/cost_query/query_helper.rb +++ b/spec/models/cost_query/query_helper.rb @@ -1,8 +1,14 @@ -class Spec::Rails::Example::ModelExampleGroup - def minimal_query - before do - @query = CostQuery.new - @query.send(:minimal_chain!) +module Reporting + module QueryHelper + def minimal_query + before do + @query = CostQuery.new + @query.send(:minimal_chain!) + end end end end + +Rspec.configure do |c| + c.extend Reporting::QueryHelper, :reporting_query_helper => true +end diff --git a/spec/models/cost_query/result_spec.rb b/spec/models/cost_query/result_spec.rb index 69d9331f4d..4d6a8b6545 100644 --- a/spec/models/cost_query/result_spec.rb +++ b/spec/models/cost_query/result_spec.rb @@ -1,6 +1,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +require_relative 'query_helper' -describe CostQuery do +describe CostQuery, :reporting_query_helper => true do before { User.current = users(:admin) } minimal_query diff --git a/spec/models/cost_query/walker_spec.rb b/spec/models/cost_query/walker_spec.rb index 55e757df99..32b7b8d269 100644 --- a/spec/models/cost_query/walker_spec.rb +++ b/spec/models/cost_query/walker_spec.rb @@ -1,6 +1,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +require_relative 'query_helper' -describe CostQuery do +describe CostQuery, :reporting_query_helper => true do minimal_query fixtures :users diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4eac9308f6..17197f6f9e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,4 @@ -RAILS_ENV = "test" +require 'spec_helper' # prevent case where we are using rubygems and test-unit 2.x is installed begin @@ -7,31 +7,16 @@ begin rescue LoadError end -begin - require 'spec/spec_helper' -rescue LoadError => error - puts <<-EOS - - You need to install rspec in your Redmine project. - Please execute the following code: - - gem install rspec-rails - script/generate rspec - - EOS - raise error -end def l(*args) I18n.t(*args) end -Fixtures.create_fixtures File.join(File.dirname(__FILE__), "fixtures"), ActiveRecord::Base.connection.tables -require File.join(RAILS_ROOT, "test", "object_daddy_helpers.rb") -Dir.glob(File.expand_path("#{__FILE__}/../../../redmine_costs/test/exemplars/*.rb")) { |e| require e } -Dir.glob(File.expand_path("#{__FILE__}/../models/helpers/*_helper.rb")) { |e| require e } - -require 'redmine_factory_girl' +# not sure whether these are required - commenting them out for now +# - mfrister +# require File.join(RAILS_ROOT, "test", "object_daddy_helpers.rb") +# Dir.glob(File.expand_path("#{__FILE__}/../../../redmine_costs/test/exemplars/*.rb")) { |e| require e } +# Dir.glob(File.expand_path("#{__FILE__}/../models/helpers/*_helper.rb")) { |e| require e } def login_user(user) @controller.send(:logged_user=, user)