OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/spec/requests/api/v3/root_resource_spec.rb

53 lines
1.4 KiB

require 'spec_helper'
require 'rack/test'
describe 'API v3 Root 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) }
describe '#get' do
subject(:response) { last_response }
let(:get_path) { "/api/v3" }
context 'anonymous user' do
before do
get get_path
end
it 'should respond with 200' do
expect(subject.status).to eq(200)
end
it 'should respond with links' do
expect(subject.body).to have_json_path('_links/priorities')
expect(subject.body).to have_json_path('_links/project')
expect(subject.body).to have_json_path('_links/statuses')
end
end
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!
get get_path
end
it 'should respond with 200' do
expect(subject.status).to eq(200)
end
it 'should respond with links' do
expect(subject.body).to have_json_path('_links/priorities')
expect(subject.body).to have_json_path('_links/project')
expect(subject.body).to have_json_path('_links/statuses')
end
end
end
end