|
|
@ -41,40 +41,47 @@ describe ::API::V3::Versions::VersionRepresenter do |
|
|
|
|
|
|
|
|
|
|
|
it { should include_json('Version'.to_json).at_path('_type') } |
|
|
|
it { should include_json('Version'.to_json).at_path('_type') } |
|
|
|
|
|
|
|
|
|
|
|
context 'links' do |
|
|
|
describe 'links' do |
|
|
|
|
|
|
|
|
|
|
|
it { should have_json_type(Object).at_path('_links') } |
|
|
|
it { should have_json_type(Object).at_path('_links') } |
|
|
|
|
|
|
|
|
|
|
|
it 'to self' do |
|
|
|
describe 'to self' do |
|
|
|
path = api_v3_paths.version(version.id) |
|
|
|
it_behaves_like 'has a titled link' do |
|
|
|
|
|
|
|
let(:link) { 'self' } |
|
|
|
expect(subject).to be_json_eql(path.to_json).at_path('_links/self/href') |
|
|
|
let(:href) { api_v3_paths.version(version.id) } |
|
|
|
|
|
|
|
let(:title) { version.name } |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context 'to the defining project' do |
|
|
|
describe 'to the defining project' do |
|
|
|
let(:path) { api_v3_paths.project(version.project.id) } |
|
|
|
context 'if the user has the permission to see the project' do |
|
|
|
|
|
|
|
before do |
|
|
|
it 'exists if the user has the permission to see the project' do |
|
|
|
|
|
|
|
allow(version.project).to receive(:visible?).with(user).and_return(true) |
|
|
|
allow(version.project).to receive(:visible?).with(user).and_return(true) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
subject = representer.to_json |
|
|
|
it_behaves_like 'has a titled link' do |
|
|
|
|
|
|
|
let(:link) { 'definingProject' } |
|
|
|
expect(subject).to be_json_eql(path.to_json).at_path('_links/definingProject/href') |
|
|
|
let(:href) { api_v3_paths.project(version.project.id) } |
|
|
|
|
|
|
|
let(:title) { version.project.name } |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'does not exist if the user lacks the permission to see the project' do |
|
|
|
context 'if the user lacks the permission to see the project' do |
|
|
|
|
|
|
|
before do |
|
|
|
allow(version.project).to receive(:visible?).with(user).and_return(false) |
|
|
|
allow(version.project).to receive(:visible?).with(user).and_return(false) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
subject = representer.to_json |
|
|
|
it_behaves_like 'has no link' do |
|
|
|
|
|
|
|
let(:link) { 'definingProject' } |
|
|
|
expect(subject).to_not have_json_path('_links/definingProject/href') |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'to available projects' do |
|
|
|
describe 'to available projects' do |
|
|
|
path = api_v3_paths.versions_projects(version.id) |
|
|
|
it_behaves_like 'has an untitled link' do |
|
|
|
|
|
|
|
let(:link) { 'availableInProjects' } |
|
|
|
expect(subject).to be_json_eql(path.to_json).at_path('_links/availableInProjects/href') |
|
|
|
let(:href) { api_v3_paths.versions_projects(version.id) } |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|