-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(matrix badges): add badge for provider/tag and consumer/tag
- Loading branch information
Showing
8 changed files
with
198 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'pact_broker/api/resources/badge' | ||
|
||
module PactBroker | ||
module Api | ||
module Resources | ||
class MatrixBadge < Badge | ||
|
||
private | ||
|
||
def latest_verification | ||
@latest_verification ||= begin | ||
matrix_row = matrix_service.find_for_consumer_and_provider_with_tags(identifier_from_path) | ||
if matrix_row && matrix_row[:verification_id] | ||
verification_service.find_by_id(matrix_row[:verification_id]) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'webmock/rspec' | ||
|
||
describe "get latest matrix badge with tags" do | ||
|
||
before do | ||
PactBroker.configuration.enable_public_badge_access = true | ||
TestDataBuilder.new | ||
.create_consumer('consumer') | ||
.create_provider('provider') | ||
.create_consumer_version('1') | ||
.create_consumer_version_tag('prod') | ||
.create_pact | ||
.create_verification(provider_version: '4') | ||
.use_provider_version('4') | ||
.create_provider_version_tag('master') | ||
end | ||
|
||
let!(:http_request) do | ||
stub_request(:get, /http/).to_return(:status => 200, :body => "<svg/>") | ||
end | ||
|
||
let(:path) { "/matrix/provider/provider/latest/master/consumer/consumer/latest/prod/badge" } | ||
|
||
# In the full app, the .svg extension is turned into an Accept header | ||
# by ConvertFileExtensionToAcceptHeader | ||
|
||
subject { get path, nil, {'HTTP_ACCEPT' => "image/svg+xml"}; last_response } | ||
|
||
it "returns a 200 status" do | ||
expect(subject.status).to eq 200 | ||
end | ||
|
||
it "returns an svg/xml response" do | ||
expect(subject.headers['Content-Type']).to include("image/svg+xml") | ||
end | ||
|
||
it "returns an svg body" do | ||
expect(subject.body).to include "<svg/>" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'pact_broker/api/resources/matrix_badge' | ||
|
||
module PactBroker | ||
module Api | ||
module Resources | ||
describe MatrixBadge do | ||
# spec is in spec/lib/pact_broker/api/resources/badge_spec.rb#123 to avoid duplication | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters