Fix/cache query representers (#5711)

* cache various query representers json representation

* sort by
* columns
* group by
* filter instance schemas

* fix custom option path

[ci skip]
pull/5722/head
ulferts 7 years ago committed by Oliver Günther
parent 0fdd757890
commit 7ad39ec35f
  1. 59
      lib/api/utilities/representer_to_json_cache.rb
  2. 6
      lib/api/v3/queries/columns/query_column_representer.rb
  3. 4
      lib/api/v3/queries/columns/query_relation_of_type_column_representer.rb
  4. 4
      lib/api/v3/queries/columns/query_relation_to_type_column_representer.rb
  5. 8
      lib/api/v3/queries/group_bys/query_group_by_representer.rb
  6. 8
      lib/api/v3/queries/schemas/assigned_to_filter_dependency_representer.rb
  7. 4
      lib/api/v3/queries/schemas/category_filter_dependency_representer.rb
  8. 6
      lib/api/v3/queries/schemas/custom_option_filter_dependency_representer.rb
  9. 1
      lib/api/v3/queries/schemas/date_time_filter_dependency_representer.rb
  10. 9
      lib/api/v3/queries/schemas/filter_dependency_representer.rb
  11. 4
      lib/api/v3/queries/schemas/group_filter_dependency_representer.rb
  12. 4
      lib/api/v3/queries/schemas/id_filter_dependency_representer.rb
  13. 2
      lib/api/v3/queries/schemas/query_filter_instance_schema_api.rb
  14. 20
      lib/api/v3/queries/schemas/query_filter_instance_schema_representer.rb
  15. 3
      lib/api/v3/queries/schemas/status_filter_dependency_representer.rb
  16. 5
      lib/api/v3/queries/schemas/subproject_filter_dependency_representer.rb
  17. 5
      lib/api/v3/queries/schemas/type_filter_dependency_representer.rb
  18. 4
      lib/api/v3/queries/schemas/user_filter_dependency_representer.rb
  19. 4
      lib/api/v3/queries/schemas/version_filter_dependency_representer.rb
  20. 7
      lib/api/v3/queries/sort_bys/query_sort_by_representer.rb
  21. 47
      spec/lib/api/v3/queries/columns/query_property_column_representer_spec.rb
  22. 38
      spec/lib/api/v3/queries/columns/query_relation_of_type_column_representer_spec.rb
  23. 47
      spec/lib/api/v3/queries/columns/query_relation_to_type_column_representer_spec.rb
  24. 48
      spec/lib/api/v3/queries/group_bys/query_group_by_representer_spec.rb
  25. 57
      spec/lib/api/v3/queries/schemas/assigned_to_filter_dependency_representer_spec.rb
  26. 36
      spec/lib/api/v3/queries/schemas/boolean_filter_dependency_representer_spec.rb
  27. 49
      spec/lib/api/v3/queries/schemas/category_filter_dependency_representer_spec.rb
  28. 62
      spec/lib/api/v3/queries/schemas/custom_option_filter_dependency_representer_spec.rb
  29. 40
      spec/lib/api/v3/queries/schemas/date_filter_dependency_representer_spec.rb
  30. 40
      spec/lib/api/v3/queries/schemas/date_time_filter_dependency_representer_spec.rb
  31. 40
      spec/lib/api/v3/queries/schemas/float_filter_dependency_representer_spec.rb
  32. 46
      spec/lib/api/v3/queries/schemas/group_filter_dependency_representer_spec.rb
  33. 46
      spec/lib/api/v3/queries/schemas/id_filter_dependency_representer_spec.rb
  34. 39
      spec/lib/api/v3/queries/schemas/integer_filter_dependency_representer_spec.rb
  35. 39
      spec/lib/api/v3/queries/schemas/priority_filter_dependency_representer_spec.rb
  36. 36
      spec/lib/api/v3/queries/schemas/project_filter_dependency_representer_spec.rb
  37. 77
      spec/lib/api/v3/queries/schemas/query_filter_instance_schema_representer_spec.rb
  38. 36
      spec/lib/api/v3/queries/schemas/role_filter_dependency_representer_spec.rb
  39. 36
      spec/lib/api/v3/queries/schemas/status_filter_dependency_representer_spec.rb
  40. 49
      spec/lib/api/v3/queries/schemas/subproject_filter_dependency_representer_spec.rb
  41. 39
      spec/lib/api/v3/queries/schemas/text_filter_dependency_representer_spec.rb
  42. 46
      spec/lib/api/v3/queries/schemas/type_filter_dependency_representer_spec.rb
  43. 46
      spec/lib/api/v3/queries/schemas/user_filter_dependency_representer_spec.rb
  44. 46
      spec/lib/api/v3/queries/schemas/version_filter_dependency_representer_spec.rb
  45. 50
      spec/lib/api/v3/queries/sort_bys/query_sort_by_representer_spec.rb
  46. 38
      spec/support/shared/clear_cache.rb

@ -0,0 +1,59 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
module API
module Utilities
module RepresenterToJsonCache
def to_json(*)
if json_cacheable?
OpenProject::Cache.fetch(*json_representer_name_cache_key, *json_cache_key) do
super
end
else
super
end
end
def json_cacheable?
true
end
def json_cache_key
raise NotImplementedError
end
private
def json_representer_name_cache_key
self.class.name.to_s.split('::') + ['json', I18n.locale]
end
end
end
end

@ -33,6 +33,8 @@ module API
module Queries
module Columns
class QueryColumnRepresenter < ::API::Decorators::Single
include API::Utilities::RepresenterToJsonCache
self_link path: 'query_column',
id_attribute: ->(*) { converted_name },
title_getter: ->(*) { represented.caption }
@ -56,6 +58,10 @@ module API
def convert_attribute(attribute)
::API::Utilities::PropertyNameConverter.from_ar_name(attribute)
end
def json_cache_key
[represented.name, represented.caption]
end
end
end
end

@ -39,6 +39,10 @@ module API
property :relation_type
end
def json_cache_key
[represented.name]
end
end
end
end

@ -43,6 +43,10 @@ module API
def _type
'QueryColumn::RelationToType'
end
def json_cache_key
[represented.name, represented.type.cache_key]
end
end
end
end

@ -1,4 +1,5 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
@ -32,9 +33,10 @@ module API
module Queries
module GroupBys
class QueryGroupByRepresenter < ::API::Decorators::Single
include API::Utilities::RepresenterToJsonCache
self_link id_attribute: ->(*) { converted_name },
title_getter: ->(*) { represented.caption }
def initialize(model, *_)
super(model, current_user: nil, embed_links: true)
end
@ -58,6 +60,10 @@ module API
def convert_attribute(attribute)
::API::Utilities::PropertyNameConverter.from_ar_name(attribute)
end
def json_cache_key
[represented.name, represented.caption]
end
end
end
end

@ -35,6 +35,14 @@ module API
class AssignedToFilterDependencyRepresenter <
PrincipalFilterDependencyRepresenter
def json_cache_key
if filter.project
super + [Setting.work_package_group_assignment?, filter.project.id]
else
super + [Setting.work_package_group_assignment?]
end
end
private
def filter_query

@ -35,6 +35,10 @@ module API
class CategoryFilterDependencyRepresenter <
FilterDependencyRepresenter
def json_cache_key
super + [filter.project.id]
end
def href_callback
# This filter is only available inside projects
api_v3_paths.categories(filter.project.identifier)

@ -47,7 +47,7 @@ module API
value_representer: CustomOptions::CustomOptionRepresenter,
link_factory: ->(value) {
{
href: api_v3_paths.custom_option(value),
href: api_v3_paths.custom_option(value.id),
title: value.to_s
}
},
@ -55,6 +55,10 @@ module API
value_required?
}
def json_cache_key
super + [filter.custom_field.cache_key]
end
private
def type

@ -1,4 +1,5 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)

@ -1,4 +1,5 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
@ -32,6 +33,8 @@ module API
module Queries
module Schemas
class FilterDependencyRepresenter < ::API::Decorators::SchemaRepresenter
include API::Utilities::RepresenterToJsonCache
def initialize(filter, operator, form_embedded: false)
self.operator = operator
@ -71,6 +74,10 @@ module API
end
end
def json_cache_key
[operator.to_sym, I18n.locale]
end
private
def value_required?
@ -78,7 +85,7 @@ module API
end
def type
raise NotImplementedError, 'Subclass has to implement #href_callback'
raise NotImplementedError, 'Subclass has to implement #type'
end
def href_callback

@ -35,6 +35,10 @@ module API
class GroupFilterDependencyRepresenter <
PrincipalFilterDependencyRepresenter
def json_cache_key
super + (filter.project.present? ? [filter.project.id] : [])
end
private
def filter_query

@ -35,6 +35,10 @@ module API
class IdFilterDependencyRepresenter <
FilterDependencyRepresenter
def json_cache_key
super + (filter.project.present? ? [filter.project.id] : [])
end
def href_callback
if filter.project
api_v3_paths.work_packages_by_project(filter.project.id)

@ -66,7 +66,7 @@ module API
filter_class = Query.find_registered_filter(ar_name)
if filter_class
filter = filter_class.new
filter = filter_class.new context: OpenStruct.new(project: nil)
filter.name = ar_name
single_representer.new(filter,

@ -28,9 +28,6 @@
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'roar/decorator'
require 'roar/json/hal'
require 'queries/operators'
module API
@ -38,6 +35,8 @@ module API
module Queries
module Schemas
class QueryFilterInstanceSchemaRepresenter < ::API::Decorators::SchemaRepresenter
include API::Utilities::RepresenterToJsonCache
schema :name,
type: 'String',
writable: false,
@ -124,7 +123,7 @@ module API
end
def dependencies
filter.available_operators.each_with_object({}) do |operator, hash|
@dependencies ||= filter.available_operators.each_with_object({}) do |operator, hash|
path = api_v3_paths.query_operator(operator.to_query)
value = FilterDependencyRepresenterFactory.create(filter,
operator,
@ -133,6 +132,19 @@ module API
hash[path] = value
end
end
def json_cacheable?
dependencies
.values
.all?(&:json_cacheable?)
end
def json_cache_key
dependencies
.values
.flat_map(&:json_cache_key)
.uniq + [form_embedded, filter.name]
end
end
end
end

@ -1,4 +1,5 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
@ -11,7 +12,7 @@
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# modif it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#

@ -1,4 +1,5 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
@ -34,6 +35,10 @@ module API
class SubprojectFilterDependencyRepresenter <
FilterDependencyRepresenter
def json_cache_key
super + [filter.project.id]
end
def href_callback
params = [ancestor: { operator: '=', values: [filter.project.id.to_s] }]
escaped = CGI.escape(::JSON.dump(params))

@ -1,4 +1,5 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
@ -34,6 +35,10 @@ module API
class TypeFilterDependencyRepresenter <
FilterDependencyRepresenter
def json_cache_key
super + (filter.project.present? ? [filter.project.id] : [])
end
def href_callback
if filter.project.nil?
api_v3_paths.types

@ -35,6 +35,10 @@ module API
class UserFilterDependencyRepresenter <
PrincipalFilterDependencyRepresenter
def json_cache_key
super + (filter.project.present? ? [filter.project.id] : [])
end
private
def filter_query

@ -35,6 +35,10 @@ module API
class VersionFilterDependencyRepresenter <
FilterDependencyRepresenter
def json_cache_key
super + (filter.project.present? ? [filter.project.id] : [])
end
def href_callback
order = "sortBy=#{to_query [%i(name asc)]}"

@ -1,4 +1,5 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
@ -32,6 +33,8 @@ module API
module Queries
module SortBys
class QuerySortByRepresenter < ::API::Decorators::Single
include API::Utilities::RepresenterToJsonCache
self_link id_attribute: ->(*) { self_link_params },
title_getter: ->(*) { represented.name }
@ -64,6 +67,10 @@ module API
def _type
'QuerySortBy'
end
def json_cache_key
[represented.column_caption, represented.direction_name]
end
end
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Columns::QueryPropertyColumnRepresenter do
describe ::API::V3::Queries::Columns::QueryPropertyColumnRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:column) { Query.available_columns.detect { |column| column.name == :status } }
@ -87,4 +87,49 @@ describe ::API::V3::Queries::Columns::QueryPropertyColumnRepresenter do
end
end
end
describe 'caching' do
before do
# fill the cache
representer.to_json
end
it 'is cached' do
expect(representer)
.not_to receive(:to_hash)
representer.to_json
end
it 'busts the cache on changes to the caption (cf rename)' do
allow(column)
.to receive(:caption)
.and_return('blubs')
expect(representer)
.to receive(:to_hash)
representer.to_json
end
it 'busts the cache on changes to the name' do
allow(column)
.to receive(:name)
.and_return('blubs')
expect(representer)
.to receive(:to_hash)
representer.to_json
end
it 'busts the cache on changes to the locale' do
expect(representer)
.to receive(:to_hash)
I18n.with_locale(:de) do
representer.to_json
end
end
end
end

@ -27,7 +27,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Columns::QueryRelationOfTypeColumnRepresenter do
describe ::API::V3::Queries::Columns::QueryRelationOfTypeColumnRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:type) { { name: :label_relates_to, sym_name: :label_relates_to, order: 1, sym: :relation1 } }
@ -60,7 +60,7 @@ describe ::API::V3::Queries::Columns::QueryRelationOfTypeColumnRepresenter do
it 'has relationType attribute' do
is_expected
.to be_json_eql(type[:sym].to_json)
.at_path('relationType')
.at_path('relationType')
end
it 'has name attribute' do
@ -69,4 +69,38 @@ describe ::API::V3::Queries::Columns::QueryRelationOfTypeColumnRepresenter do
.at_path('name')
end
end
describe 'caching' do
before do
# fill the cache
representer.to_json
end
it 'is cached' do
expect(representer)
.not_to receive(:to_hash)
representer.to_json
end
it 'busts the cache on changes to the name' do
allow(column)
.to receive(:name)
.and_return('blubs')
expect(representer)
.to receive(:to_hash)
representer.to_json
end
it 'busts the cache on changes to the locale' do
expect(representer)
.to receive(:to_hash)
I18n.with_locale(:de) do
representer.to_json
end
end
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Columns::QueryRelationToTypeColumnRepresenter do
describe ::API::V3::Queries::Columns::QueryRelationToTypeColumnRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:type) { FactoryGirl.build_stubbed(:type) }
@ -70,4 +70,49 @@ describe ::API::V3::Queries::Columns::QueryRelationToTypeColumnRepresenter do
.at_path('name')
end
end
describe 'caching' do
before do
# fill the cache
representer.to_json
end
it 'is cached' do
expect(representer)
.not_to receive(:to_hash)
representer.to_json
end
it 'busts the cache on changes to the name' do
allow(column)
.to receive(:name)
.and_return('blubs')
expect(representer)
.to receive(:to_hash)
representer.to_json
end
it 'busts the cache on changes to the type' do
allow(type)
.to receive(:cache_key)
.and_return('a_different_one')
expect(representer)
.to receive(:to_hash)
representer.to_json
end
it 'busts the cache on changes to the locale' do
expect(representer)
.to receive(:to_hash)
I18n.with_locale(:de) do
representer.to_json
end
end
end
end

@ -1,4 +1,5 @@
#-- copyright
#
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
#
@ -28,7 +29,7 @@
require 'spec_helper'
describe ::API::V3::Queries::GroupBys::QueryGroupByRepresenter do
describe ::API::V3::Queries::GroupBys::QueryGroupByRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:column) { Query.available_columns.detect { |column| column.name == :status } }
@ -87,4 +88,49 @@ describe ::API::V3::Queries::GroupBys::QueryGroupByRepresenter do
end
end
end
describe 'caching' do
before do
# fill the cache
representer.to_json
end
it 'is cached' do
expect(representer)
.not_to receive(:to_hash)
representer.to_json
end
it 'busts the cache on changes to the caption (cf rename)' do
allow(column)
.to receive(:caption)
.and_return('blubs')
expect(representer)
.to receive(:to_hash)
representer.to_json
end
it 'busts the cache on changes to the name' do
allow(column)
.to receive(:name)
.and_return('blubs')
expect(representer)
.to receive(:to_hash)
representer.to_json
end
it 'busts the cache on changes to the locale' do
expect(representer)
.to receive(:to_hash)
I18n.with_locale(:de) do
representer.to_json
end
end
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::AssignedToFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::AssignedToFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
@ -155,5 +155,60 @@ describe ::API::V3::Queries::Schemas::AssignedToFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
let(:other_project) { FactoryGirl.build_stubbed(:project) }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::All)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different project' do
query.project = other_project
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different work_package_group_assignment setting' do
allow(Setting)
.to receive(:work_package_group_assignment?)
.and_return(!Setting.work_package_group_assignment?)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::BooleanFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::BooleanFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
@ -70,5 +70,39 @@ describe ::API::V3::Queries::Schemas::BooleanFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,11 +28,12 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::CategoryFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::CategoryFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
let(:filter) { Queries::WorkPackages::Filter::CategoryFilter.new(context: project) }
let(:query) { FactoryGirl.build_stubbed(:query, project: project) }
let(:filter) { Queries::WorkPackages::Filter::CategoryFilter.new(context: query) }
let(:form_embedded) { false }
let(:instance) do
@ -75,5 +76,49 @@ describe ::API::V3::Queries::Schemas::CategoryFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
let(:other_project) { FactoryGirl.build_stubbed(:project) }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different project' do
query.project = other_project
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,13 +28,22 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::CustomOptionFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::CustomOptionFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
let(:custom_field) { FactoryGirl.build_stubbed(:list_wp_custom_field) }
let(:query) { FactoryGirl.build_stubbed(:query, project: project) }
let(:custom_field) do
cf = FactoryGirl.build_stubbed(:list_wp_custom_field)
allow(cf)
.to receive(:custom_options)
.and_return([FactoryGirl.build_stubbed(:custom_option),
FactoryGirl.build_stubbed(:custom_option)])
cf
end
let(:filter) do
filter = Queries::WorkPackages::Filter::CustomFieldFilter.new(context: project)
filter = Queries::WorkPackages::Filter::CustomFieldFilter.new(context: query)
filter.custom_field = custom_field
filter
end
@ -55,7 +64,7 @@ describe ::API::V3::Queries::Schemas::CustomOptionFilterDependencyRepresenter do
let(:type) { '[]CustomOption' }
let(:hrefs) do
custom_field.custom_options.map do |value|
api_v3_paths.custom_option(value)
api_v3_paths.custom_option(value.id)
end
end
@ -84,5 +93,50 @@ describe ::API::V3::Queries::Schemas::CustomOptionFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different cache_key' do
allow(custom_field)
.to receive(:cache_key)
.and_return('something else')
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,11 +28,12 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::DateFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::DateFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
let(:filter) { Queries::WorkPackages::Filter::DueDateFilter.new(context: project) }
let(:query) { FactoryGirl.build_stubbed(:query, project: project) }
let(:filter) { Queries::WorkPackages::Filter::DueDateFilter.new(context: query) }
let(:form_embedded) { false }
let(:instance) do
@ -106,5 +107,40 @@ describe ::API::V3::Queries::Schemas::DateFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
let(:other_project) { FactoryGirl.build_stubbed(:project) }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,11 +28,12 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::DateTimeFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::DateTimeFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
let(:filter) { Queries::WorkPackages::Filter::CreatedAtFilter.new(context: project) }
let(:query) { FactoryGirl.build_stubbed(:query, project: project) }
let(:filter) { Queries::WorkPackages::Filter::CreatedAtFilter.new(context: query) }
let(:form_embedded) { false }
let(:instance) do
@ -95,5 +96,40 @@ describe ::API::V3::Queries::Schemas::DateTimeFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
let(:other_project) { FactoryGirl.build_stubbed(:project) }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,13 +28,14 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::FloatFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::FloatFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
let(:query) { FactoryGirl.build_stubbed(:query, project: project) }
let(:custom_field) { FactoryGirl.build_stubbed(:float_wp_custom_field) }
let(:filter) do
filter = Queries::WorkPackages::Filter::CustomFieldFilter.new(context: project)
filter = Queries::WorkPackages::Filter::CustomFieldFilter.new(context: query)
filter.custom_field = custom_field
filter
end
@ -91,5 +92,40 @@ describe ::API::V3::Queries::Schemas::FloatFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
let(:other_project) { FactoryGirl.build_stubbed(:project) }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::GroupFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::GroupFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
@ -106,5 +106,49 @@ describe ::API::V3::Queries::Schemas::GroupFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
let(:other_project) { FactoryGirl.build_stubbed(:project) }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different project' do
query.project = other_project
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::IdFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::IdFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
@ -85,5 +85,49 @@ describe ::API::V3::Queries::Schemas::IdFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
let(:other_project) { FactoryGirl.build_stubbed(:project) }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different project' do
query.project = other_project
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,11 +28,12 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::IntegerFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::IntegerFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
let(:filter) { Queries::WorkPackages::Filter::DoneRatioFilter.new(context: project) }
let(:query) { FactoryGirl.build_stubbed(:query, project: project) }
let(:filter) { Queries::WorkPackages::Filter::DoneRatioFilter.new(context: query) }
let(:form_embedded) { false }
let(:instance) do
@ -86,5 +87,39 @@ describe ::API::V3::Queries::Schemas::IntegerFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,11 +28,12 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::PriorityFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::PriorityFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
let(:filter) { Queries::WorkPackages::Filter::PriorityFilter.new(context: project) }
let(:query) { FactoryGirl.build_stubbed(:query, project: project) }
let(:filter) { Queries::WorkPackages::Filter::PriorityFilter.new(context: query) }
let(:form_embedded) { false }
let(:instance) do
@ -63,5 +64,39 @@ describe ::API::V3::Queries::Schemas::PriorityFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::ProjectFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::ProjectFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:filter) { Queries::WorkPackages::Filter::ProjectFilter.new }
@ -74,5 +74,39 @@ describe ::API::V3::Queries::Schemas::ProjectFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::QueryFilterInstanceSchemaRepresenter do
describe ::API::V3::Queries::Schemas::QueryFilterInstanceSchemaRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:filter) { Queries::WorkPackages::Filter::StatusFilter.new }
@ -56,6 +56,14 @@ describe ::API::V3::Queries::Schemas::QueryFilterInstanceSchemaRepresenter do
let(:self_link) { 'bogus_self_path' }
let(:project) { nil }
let(:user) { FactoryGirl.build_stubbed(:user) }
let(:json_cacheable) { true }
let(:json_cache_key) { 'some key' }
let(:dependency) do
double('dependency',
to_hash: { 'lorem': 'ipsum' },
json_cacheable?: json_cacheable,
json_cache_key: json_cache_key)
end
context 'generation' do
before do
@ -65,7 +73,7 @@ describe ::API::V3::Queries::Schemas::QueryFilterInstanceSchemaRepresenter do
.with(filter,
operator,
form_embedded: form_embedded)
.and_return("lorem": "ipsum")
.and_return(dependency)
end
end
@ -213,4 +221,69 @@ describe ::API::V3::Queries::Schemas::QueryFilterInstanceSchemaRepresenter do
end
end
end
describe 'caching' do
before do
filter.available_operators.each do |operator|
allow(::API::V3::Queries::Schemas::FilterDependencyRepresenterFactory)
.to receive(:create)
.with(filter,
operator,
form_embedded: form_embedded)
.and_return(dependency)
end
end
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
context 'with an uncacheable dependency' do
let(:json_cacheable) { false }
it 'is not cached' do
expect(instance)
.to receive(:to_hash)
instance.to_json
end
end
it 'busts the cache on the form_embedded attribute' do
instance.form_embedded = !form_embedded
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different cache key from a dependency' do
allow(dependency)
.to receive(:json_cache_key)
.and_return(['and', 'now', 'to', 'something', 'completely', 'different'])
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::RoleFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::RoleFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:filter) { Queries::WorkPackages::Filter::RoleFilter.new }
@ -74,5 +74,39 @@ describe ::API::V3::Queries::Schemas::RoleFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::StatusFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::StatusFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:filter) { Queries::WorkPackages::Filter::StatusFilter.new }
@ -80,5 +80,39 @@ describe ::API::V3::Queries::Schemas::StatusFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,11 +28,12 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::SubprojectFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::SubprojectFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
let(:filter) { Queries::WorkPackages::Filter::SubprojectFilter.new(context: project) }
let(:query) { FactoryGirl.build_stubbed(:query, project: project) }
let(:filter) { Queries::WorkPackages::Filter::SubprojectFilter.new(context: query) }
let(:form_embedded) { false }
let(:instance) do
@ -74,5 +75,49 @@ describe ::API::V3::Queries::Schemas::SubprojectFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
let(:other_project) { FactoryGirl.build_stubbed(:project) }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different project' do
query.project = other_project
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,11 +28,12 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::TextFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::TextFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
let(:filter) { Queries::WorkPackages::Filter::SubjectFilter.new(context: project) }
let(:query) { FactoryGirl.build_stubbed(:query, project: project) }
let(:filter) { Queries::WorkPackages::Filter::SubjectFilter.new(context: query) }
let(:form_embedded) { false }
let(:instance) do
@ -74,5 +75,39 @@ describe ::API::V3::Queries::Schemas::TextFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::TypeFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::TypeFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
@ -88,5 +88,49 @@ describe ::API::V3::Queries::Schemas::TypeFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
let(:other_project) { FactoryGirl.build_stubbed(:project) }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different project' do
query.project = other_project
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::UserFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::UserFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed :project }
@ -91,5 +91,49 @@ describe ::API::V3::Queries::Schemas::UserFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
let(:other_project) { FactoryGirl.build_stubbed(:project) }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different project' do
query.project = other_project
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe ::API::V3::Queries::Schemas::VersionFilterDependencyRepresenter do
describe ::API::V3::Queries::Schemas::VersionFilterDependencyRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:project) { FactoryGirl.build_stubbed(:project) }
@ -104,5 +104,49 @@ describe ::API::V3::Queries::Schemas::VersionFilterDependencyRepresenter do
end
end
end
describe 'caching' do
let(:operator) { Queries::Operators::Equals }
let(:other_project) { FactoryGirl.build_stubbed(:project) }
before do
# fill the cache
instance.to_json
end
it 'is cached' do
expect(instance)
.not_to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different operator' do
instance.send(:operator=, Queries::Operators::NotEquals)
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on a different project' do
query.project = other_project
expect(instance)
.to receive(:to_hash)
instance.to_json
end
it 'busts the cache on changes to the locale' do
expect(instance)
.to receive(:to_hash)
I18n.with_locale(:de) do
instance.to_json
end
end
end
end
end

@ -28,15 +28,16 @@
require 'spec_helper'
describe ::API::V3::Queries::SortBys::QuerySortByRepresenter do
describe ::API::V3::Queries::SortBys::QuerySortByRepresenter, clear_cache: true do
include ::API::V3::Utilities::PathHelper
let(:column_name) { 'status' }
let(:direction) { 'desc' }
let(:column) { Queries::WorkPackages::Columns::PropertyColumn.new(column_name) }
let(:decorator) { ::API::V3::Queries::SortBys::SortByDecorator.new(column, direction) }
let(:representer) do
described_class
.new(::API::V3::Queries::SortBys::SortByDecorator.new(column, direction))
.new(decorator)
end
subject { representer.to_json }
@ -128,4 +129,49 @@ describe ::API::V3::Queries::SortBys::QuerySortByRepresenter do
end
end
end
describe 'caching' do
before do
# fill the cache
representer.to_json
end
it 'is cached' do
expect(representer)
.not_to receive(:to_hash)
representer.to_json
end
it 'busts the cache on changes to the column_caption (cf rename)' do
allow(decorator)
.to receive(:column_caption)
.and_return('blubs')
expect(representer)
.to receive(:to_hash)
representer.to_json
end
it 'busts the cache on a different direction' do
allow(decorator)
.to receive(:direction_name)
.and_return('asc')
expect(representer)
.to receive(:to_hash)
representer.to_json
end
it 'busts the cache on changes to the locale' do
expect(representer)
.to receive(:to_hash)
I18n.with_locale(:de) do
representer.to_json
end
end
end
end

@ -0,0 +1,38 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
RSpec.configure do |config|
config.before(:each) do |example|
clear_cache = example.metadata[:clear_cache]
if clear_cache
Rails.cache.clear
end
end
end
Loading…
Cancel
Save