Extract shared context from spec

pull/5130/head
Jan Sandbrink 9 years ago committed by Jens Ulferts
parent 69171a0e05
commit 0442e95d9b
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 10
      spec/requests/api/v3/work_package_resource_spec.rb
  2. 39
      spec/support/roles.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

@ -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
Loading…
Cancel
Save