File tree 2 files changed +29
-8
lines changed
lib/pact_broker/api/renderers
spec/lib/pact_broker/api/renderers
2 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,8 @@ def head
50
50
def pact_metadata
51
51
"<div class='pact-metadata'>
52
52
<ul>
53
- #{ badge_list_items }
53
+ #{ badge_list_item }
54
+ #{ badge_markdown_item }
54
55
<li>
55
56
<span class='name'>#{ @pact . consumer . name } version:</span>
56
57
<span class='value'>#{ @pact . consumer_version_number } #{ tags } </span>
@@ -69,20 +70,30 @@ def pact_metadata
69
70
</div>"
70
71
end
71
72
72
- def badge_list_items
73
- if PactBroker . configuration . enable_public_badge_access
73
+ def badge_list_item
74
74
"<li class='badge'>
75
75
<img src='#{ badge_url } '/>
76
76
</li>
77
- <li class='badge-markdown' style='display:none'>
78
- <textarea rows='3' cols='100'>#{ badge_markdown } </textarea>
79
- </li>
80
77
"
81
- end
78
+ end
79
+
80
+ def badge_markdown_item
81
+ "<li class='badge-markdown' style='display:none'>
82
+ <textarea rows='3' cols='100'>#{ badge_markdown } </textarea>
83
+ </li>"
82
84
end
83
85
84
86
def badge_markdown
85
- "[](#{ badge_target_url } )"
87
+ warning = if badges_protected?
88
+ "If the broker is protected by authentication, set `enable_public_badge_access` to true in the configuration to enable badges to be embedded in a markdown file.\n "
89
+ else
90
+ ""
91
+ end
92
+ "#{ warning } [](#{ badge_target_url } )"
93
+ end
94
+
95
+ def badges_protected?
96
+ !PactBroker . configuration . enable_public_badge_access
86
97
end
87
98
88
99
def base_url
Original file line number Diff line number Diff line change @@ -60,6 +60,16 @@ module Renderers
60
60
expect ( subject ) . to include "[](http://base)"
61
61
end
62
62
63
+ context "when enable_public_badge_access is false" do
64
+ before do
65
+ PactBroker . configuration . enable_public_badge_access = false
66
+ end
67
+
68
+ it "renders a message instructing the user to turn public access on" do
69
+ expect ( subject ) . to include "set `enable_public_badge_access` to true in the configuration"
70
+ end
71
+ end
72
+
63
73
context "when the content is not a valid pact, but is still JSON" do
64
74
before do
65
75
allow ( pact ) . to receive ( :content_hash ) . and_return ( content_hash )
You can’t perform that action at this time.
0 commit comments