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/version_resource_spec.rb

40 lines
1.2 KiB

require 'spec_helper'
require 'rack/test'
describe 'API v3 Version 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(:versions) { FactoryGirl.create_list(:version, 4, project: project) }
let(:other_versions) { FactoryGirl.create_list(:version, 2) }
describe '#get' do
subject(:response) { last_response }
context 'logged in user' do
let(:get_path) { "/api/v3/projects/#{project.id}/versions" }
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!
versions
other_versions
get get_path
end
it 'should respond with 200' do
expect(subject.status).to eq(200)
end
it 'should respond with versions, scoped to project' do
expect(subject.body).to include_json('Versions'.to_json).at_path('_type')
expect(subject.body).to have_json_size(4).at_path('_embedded/versions')
end
end
end
end