diff --git a/spec/requests/api/v3/work_package_resource_spec.rb b/spec/requests/api/v3/work_package_resource_spec.rb index 4050d80849..6faddfb400 100644 --- a/spec/requests/api/v3/work_package_resource_spec.rb +++ b/spec/requests/api/v3/work_package_resource_spec.rb @@ -89,18 +89,10 @@ describe 'API v3 Work package resource', type: :request do end context 'user not seeing any work packages' do + include_context 'with non-member permissions from non_member_permissions' let(:current_user) { FactoryGirl.create(:user) } let(:non_member_permissions) { [:view_work_packages] } - around do |example| - non_member = Role.non_member - previous_permissions = non_member.permissions - - non_member.update_attribute(:permissions, non_member_permissions) - example.run - non_member.update_attribute(:permissions, previous_permissions) - end - it 'succeeds' do expect(subject.status).to eql 200 end diff --git a/spec/support/roles.rb b/spec/support/roles.rb new file mode 100644 index 0000000000..56835e595a --- /dev/null +++ b/spec/support/roles.rb @@ -0,0 +1,39 @@ +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2015 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-2013 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. +#++ + +# +shared_context 'with non-member permissions from non_member_permissions' do + around do |example| + non_member = Role.non_member + previous_permissions = non_member.permissions + + non_member.update_attribute(:permissions, non_member_permissions) + example.run + non_member.update_attribute(:permissions, previous_permissions) + end +end