|
|
@@ -927,16 +927,23 @@ RSpec.describe 'Posts API', type: :request do |
|
|
) |
|
|
) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
it 'matches tag filter against current tags snapshot only' do |
|
|
|
|
|
|
|
|
it 'filters versions by tag when the tag exists in either current or previous snapshot' do |
|
|
get '/posts/versions', params: { post: post_record.id, tag: tag.id } |
|
|
get '/posts/versions', params: { post: post_record.id, tag: tag.id } |
|
|
|
|
|
|
|
|
expect(response).to have_http_status(:ok) |
|
|
expect(response).to have_http_status(:ok) |
|
|
expect(json.fetch('count')).to eq(1) |
|
|
|
|
|
|
|
|
expect(json.fetch('count')).to eq(2) |
|
|
|
|
|
|
|
|
versions = json.fetch('versions') |
|
|
versions = json.fetch('versions') |
|
|
expect(versions.size).to eq(1) |
|
|
|
|
|
expect(versions[0]['version_no']).to eq(1) |
|
|
|
|
|
expect(versions[0]['tags']).to include( |
|
|
|
|
|
|
|
|
expect(versions.map { |v| v['post_id'] }).to all(eq(post_record.id)) |
|
|
|
|
|
expect(versions.map { |v| v['version_no'] }).to eq([2, 1]) |
|
|
|
|
|
|
|
|
|
|
|
latest = versions[0] |
|
|
|
|
|
first = versions[1] |
|
|
|
|
|
|
|
|
|
|
|
expect(latest['tags']).to include( |
|
|
|
|
|
{ 'name' => 'spec_tag', 'type' => 'removed' } |
|
|
|
|
|
) |
|
|
|
|
|
expect(first['tags']).to include( |
|
|
{ 'name' => 'spec_tag', 'type' => 'added' } |
|
|
{ 'name' => 'spec_tag', 'type' => 'added' } |
|
|
) |
|
|
) |
|
|
end |
|
|
end |
|
|
|