use more condensed way of creating users

- also remove requires that seem to have failed the status_resource_spec for me
pull/2456/head
Jan Sandbrink 10 years ago
parent 855267af68
commit f2e6048a45
  1. 4
      lib/api/v3/statuses/status_collection_representer.rb
  2. 19
      spec/requests/api/v3/priority_resource_spec.rb
  3. 14
      spec/requests/api/v3/status_resource_spec.rb

@ -27,10 +27,6 @@
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'roar/decorator'
require 'roar/json/collection'
require 'roar/json/hal'
module API
module V3
module Statuses

@ -32,10 +32,15 @@ require 'rack/test'
describe 'API v3 Priority resource' do
include Rack::Test::Methods
let(:current_user) { FactoryGirl.create(:user) }
let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) }
let(:project) { FactoryGirl.create(:project, is_public: false) }
let(:priorities) { FactoryGirl.create_list(:priority, 2) }
let(:current_user) do
FactoryGirl.create(:user,
member_in_project: project,
member_through_role: role)
end
let!(:priorities) { FactoryGirl.create_list(:priority, 2) }
describe 'priorities' do
subject(:response) { last_response }
@ -45,11 +50,6 @@ describe 'API v3 Priority resource' do
context 'logged in user' do
before do
allow(User).to receive(:current).and_return current_user
member = FactoryGirl.build(:member, user: current_user, project: project)
member.role_ids = [role.id]
member.save!
priorities
get get_path
end
@ -77,11 +77,6 @@ describe 'API v3 Priority resource' do
context 'logged in user' do
before do
allow(User).to receive(:current).and_return current_user
member = FactoryGirl.build(:member, user: current_user, project: project)
member.role_ids = [role.id]
member.save!
priorities
get get_path
end

@ -32,10 +32,15 @@ require 'rack/test'
describe 'API v3 Status resource' do
include Rack::Test::Methods
let(:current_user) { FactoryGirl.create(:user) }
let(:role) { FactoryGirl.create(:role, permissions: []) }
let(:project) { FactoryGirl.create(:project, is_public: false) }
let(:statuses) { FactoryGirl.create_list(:status, 4) }
let(:current_user) do
FactoryGirl.create(:user,
member_in_project: project,
member_through_role: role)
end
let!(:statuses) { FactoryGirl.create_list(:status, 4) }
describe 'statuses' do
describe '#get' do
@ -45,11 +50,6 @@ describe 'API v3 Status resource' do
let(:get_path) { '/api/v3/statuses' }
before do
allow(User).to receive(:current).and_return current_user
member = FactoryGirl.build(:member, user: current_user, project: project)
member.role_ids = [role.id]
member.save!
statuses
get get_path
end

Loading…
Cancel
Save