From 5b58d77c05170fa9b5ccd18e1846a77f36aabfc1 Mon Sep 17 00:00:00 2001 From: Wieland Lindenthal Date: Fri, 26 Jan 2018 10:31:35 +0100 Subject: [PATCH] Adding pretty generic specs for attachment filters. --- .../filter/attachment_content_filter_spec.rb | 62 +++++++++++++++++++ .../attachment_file_name_filter_spec.rb | 62 +++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 spec/models/queries/work_packages/filter/attachment_content_filter_spec.rb create mode 100644 spec/models/queries/work_packages/filter/attachment_file_name_filter_spec.rb diff --git a/spec/models/queries/work_packages/filter/attachment_content_filter_spec.rb b/spec/models/queries/work_packages/filter/attachment_content_filter_spec.rb new file mode 100644 index 0000000000..9bd6e18ecd --- /dev/null +++ b/spec/models/queries/work_packages/filter/attachment_content_filter_spec.rb @@ -0,0 +1,62 @@ +#-- 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. +#++ + +require 'spec_helper' + +describe Queries::WorkPackages::Filter::AttachmentContentFilter, type: :model do + it_behaves_like 'basic query filter' do + let(:order) { 8 } + let(:type) { :text } + let(:class_key) { :attachment_content } + + describe '#available?' do + it 'is available' do + expect(instance).to be_available + end + end + + describe '#allowed_values' do + it 'is nil' do + expect(instance.allowed_values).to be_nil + end + end + + describe '#valid_values!' do + it 'is a noop' do + instance.values = ['none', 'is', 'changed'] + + instance.valid_values! + + expect(instance.values) + .to match_array ['none', 'is', 'changed'] + end + end + + it_behaves_like 'non ar filter' + end +end diff --git a/spec/models/queries/work_packages/filter/attachment_file_name_filter_spec.rb b/spec/models/queries/work_packages/filter/attachment_file_name_filter_spec.rb new file mode 100644 index 0000000000..8b1511bc5b --- /dev/null +++ b/spec/models/queries/work_packages/filter/attachment_file_name_filter_spec.rb @@ -0,0 +1,62 @@ +#-- 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. +#++ + +require 'spec_helper' + +describe Queries::WorkPackages::Filter::AttachmentFileNameFilter, type: :model do + it_behaves_like 'basic query filter' do + let(:order) { 8 } + let(:type) { :text } + let(:class_key) { :attachment_file_name } + + describe '#available?' do + it 'is available' do + expect(instance).to be_available + end + end + + describe '#allowed_values' do + it 'is nil' do + expect(instance.allowed_values).to be_nil + end + end + + describe '#valid_values!' do + it 'is a noop' do + instance.values = ['none', 'is', 'changed'] + + instance.valid_values! + + expect(instance.values) + .to match_array ['none', 'is', 'changed'] + end + end + + it_behaves_like 'non ar filter' + end +end