pact_broker 2.52.1 → 2.56.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +80 -0
  3. data/CODE_OF_CONDUCT.md +76 -0
  4. data/README.md +2 -4
  5. data/db/migrations/20180828_create_latest_versions.rb +1 -1
  6. data/lib/pact_broker/api.rb +8 -0
  7. data/lib/pact_broker/api/contracts/webhook_contract.rb +8 -6
  8. data/lib/pact_broker/api/decorators/decorator_context.rb +6 -11
  9. data/lib/pact_broker/api/decorators/reason_decorator.rb +17 -0
  10. data/lib/pact_broker/api/decorators/webhook_execution_result_decorator.rb +6 -1
  11. data/lib/pact_broker/api/pact_broker_urls.rb +6 -2
  12. data/lib/pact_broker/api/renderers/html_pact_renderer.rb +14 -14
  13. data/lib/pact_broker/api/resources/badge.rb +6 -2
  14. data/lib/pact_broker/api/resources/base_resource.rb +3 -3
  15. data/lib/pact_broker/api/resources/matrix_badge.rb +5 -0
  16. data/lib/pact_broker/api/resources/pact.rb +1 -17
  17. data/lib/pact_broker/api/resources/pacticipant.rb +0 -4
  18. data/lib/pact_broker/api/resources/pacticipants.rb +3 -2
  19. data/lib/pact_broker/api/resources/verifications.rb +0 -4
  20. data/lib/pact_broker/app.rb +13 -4
  21. data/lib/pact_broker/badges/service.rb +16 -13
  22. data/lib/pact_broker/db.rb +9 -1
  23. data/lib/pact_broker/doc/controllers/app.rb +11 -1
  24. data/lib/pact_broker/doc/views/layouts/main.haml +1 -1
  25. data/lib/pact_broker/domain/verification.rb +13 -0
  26. data/lib/pact_broker/hash_refinements.rb +4 -0
  27. data/lib/pact_broker/integrations/service.rb +2 -2
  28. data/lib/pact_broker/locale/en.yml +1 -1
  29. data/lib/pact_broker/logging.rb +3 -1
  30. data/lib/pact_broker/matrix/deployment_status_summary.rb +23 -1
  31. data/lib/pact_broker/matrix/reason.rb +9 -0
  32. data/lib/pact_broker/matrix/unresolved_selector.rb +4 -0
  33. data/lib/pact_broker/pacticipants/repository.rb +6 -0
  34. data/lib/pact_broker/pacticipants/service.rb +8 -0
  35. data/lib/pact_broker/pacts/content.rb +26 -2
  36. data/lib/pact_broker/pacts/repository.rb +5 -4
  37. data/lib/pact_broker/tasks/migration_task.rb +20 -1
  38. data/lib/pact_broker/test/test_data_builder.rb +8 -3
  39. data/lib/pact_broker/ui/app.rb +1 -0
  40. data/lib/pact_broker/ui/controllers/base_controller.rb +3 -0
  41. data/lib/pact_broker/ui/controllers/clusters.rb +2 -2
  42. data/lib/pact_broker/ui/controllers/groups.rb +3 -2
  43. data/lib/pact_broker/ui/controllers/index.rb +3 -2
  44. data/lib/pact_broker/ui/controllers/matrix.rb +19 -3
  45. data/lib/pact_broker/ui/helpers/url_helper.rb +4 -4
  46. data/lib/pact_broker/ui/view_models/index_item.rb +16 -11
  47. data/lib/pact_broker/ui/view_models/index_items.rb +2 -2
  48. data/lib/pact_broker/ui/view_models/matrix_line.rb +12 -7
  49. data/lib/pact_broker/ui/view_models/matrix_lines.rb +2 -2
  50. data/lib/pact_broker/ui/views/groups/show.html.erb +3 -3
  51. data/lib/pact_broker/ui/views/index/_css_and_js.haml +9 -9
  52. data/lib/pact_broker/ui/views/index/_navbar.haml +3 -3
  53. data/lib/pact_broker/ui/views/index/_pagination.haml +1 -1
  54. data/lib/pact_broker/ui/views/index/show-with-tags.haml +3 -3
  55. data/lib/pact_broker/ui/views/index/show.haml +3 -3
  56. data/lib/pact_broker/ui/views/layouts/main.haml +4 -4
  57. data/lib/pact_broker/ui/views/matrix/show.haml +14 -11
  58. data/lib/pact_broker/verifications/repository.rb +4 -5
  59. data/lib/pact_broker/version.rb +1 -1
  60. data/lib/pact_broker/webhooks/service.rb +4 -3
  61. data/lib/pact_broker/webhooks/webhook_event.rb +1 -1
  62. data/lib/pact_broker/webhooks/webhook_request_logger.rb +8 -8
  63. data/pact_broker.gemspec +2 -2
  64. data/public/javascripts/pact.js +7 -6
  65. data/public/stylesheets/matrix.css +13 -0
  66. data/script/foo-bar-verification.json +3 -1
  67. data/script/foo-bar.json +11 -0
  68. data/script/seed.rb +1 -1
  69. data/spec/features/create_webhook_spec.rb +1 -1
  70. data/spec/features/delete_integration_spec.rb +2 -2
  71. data/spec/features/get_matrix_badge_spec.rb +9 -0
  72. data/spec/fixtures/webhook_valid.json +1 -1
  73. data/spec/fixtures/webhook_valid_with_pacticipants.json +1 -1
  74. data/spec/integration/ui/index_spec.rb +16 -0
  75. data/spec/integration/ui/matrix_spec.rb +11 -4
  76. data/spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb +12 -0
  77. data/spec/lib/pact_broker/api/decorators/pact_version_decorator_spec.rb +1 -1
  78. data/spec/lib/pact_broker/api/decorators/reason_decorator_spec.rb +18 -1
  79. data/spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb +1 -1
  80. data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +8 -0
  81. data/spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb +1 -1
  82. data/spec/lib/pact_broker/api/resources/badge_spec.rb +42 -22
  83. data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +1 -1
  84. data/spec/lib/pact_broker/badges/service_spec.rb +15 -3
  85. data/spec/lib/pact_broker/doc/controllers/app_spec.rb +16 -0
  86. data/spec/lib/pact_broker/domain/version_spec.rb +7 -7
  87. data/spec/lib/pact_broker/integrations/service_spec.rb +6 -0
  88. data/spec/lib/pact_broker/matrix/deployment_status_summary_spec.rb +6 -2
  89. data/spec/lib/pact_broker/matrix/integration_spec.rb +43 -0
  90. data/spec/lib/pact_broker/pacts/content_spec.rb +125 -0
  91. data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +18 -1
  92. data/spec/lib/pact_broker/verifications/repository_spec.rb +20 -0
  93. data/spec/lib/pact_broker/webhooks/webhook_request_logger_spec.rb +4 -1
  94. data/spec/migrations/rollback_spec.rb +6 -0
  95. data/spec/service_consumers/provider_states_for_pact_broker_client.rb +11 -0
  96. data/vendor/hal-browser/README.adoc +169 -0
  97. data/vendor/hal-browser/browser.html +36 -22
  98. data/vendor/hal-browser/js/hal.js +30 -7
  99. data/vendor/hal-browser/js/hal/http/client.js +14 -6
  100. data/vendor/hal-browser/js/hal/resource.js +4 -2
  101. data/vendor/hal-browser/js/hal/views/documentation.js +1 -1
  102. data/vendor/hal-browser/js/hal/views/embedded_resource.js +10 -4
  103. data/vendor/hal-browser/js/hal/views/links.js +3 -2
  104. data/vendor/hal-browser/js/hal/views/non_safe_request_dialog.js +1 -1
  105. data/vendor/hal-browser/js/hal/views/properties.js +101 -2
  106. data/vendor/hal-browser/js/hal/views/query_uri_dialog.js +1 -1
  107. data/vendor/hal-browser/js/hal/views/request_headers.js +1 -1
  108. data/vendor/hal-browser/js/hal/views/resource.js +4 -3
  109. data/vendor/hal-browser/js/hal/views/response_headers.js +12 -1
  110. data/vendor/hal-browser/login.html +76 -0
  111. data/vendor/hal-browser/styles.css +3 -1
  112. data/vendor/hal-browser/vendor/js/URI.min.js +84 -0
  113. metadata +31 -28
  114. data/lib/pact_broker/verifications/all_verifications.rb +0 -41
  115. data/vendor/hal-browser/README.md +0 -41
@@ -107,8 +107,8 @@ module PactBroker
107
107
  end
108
108
 
109
109
  def delete_all_pact_publications_between consumer_name, options
110
- consumer = pacticipant_repository.find_by_name(consumer_name)
111
- provider = pacticipant_repository.find_by_name(options.fetch(:and))
110
+ consumer = pacticipant_repository.find_by_name!(consumer_name)
111
+ provider = pacticipant_repository.find_by_name!(options.fetch(:and))
112
112
  query = PactPublication.where(consumer: consumer, provider: provider)
113
113
  query = query.tag(options[:tag]) if options[:tag]
114
114
 
@@ -202,6 +202,7 @@ module PactBroker
202
202
  .all
203
203
 
204
204
  wip_pacts.collect do | pact|
205
+
205
206
  pending_tag_names = find_provider_tags_for_which_pact_publication_id_is_pending(pact, successfully_verified_head_pact_publication_ids_for_each_provider_tag)
206
207
  pre_existing_tag_names = find_provider_tag_names_that_were_first_used_before_pact_published(pact, provider_tag_collection)
207
208
 
@@ -356,12 +357,11 @@ module PactBroker
356
357
  selected_pacts = selected_pacts + find_pacts_for_fallback_tags(selected_pacts, provider_name, consumer_version_selectors)
357
358
 
358
359
  selected_pacts
359
- .group_by(&:pact_version_sha)
360
+ .group_by{ |p| [p.consumer_name, p.pact_version_sha] }
360
361
  .values
361
362
  .collect do | selected_pacts_for_pact_version_id |
362
363
  SelectedPact.merge(selected_pacts_for_pact_version_id)
363
364
  end
364
-
365
365
  end
366
366
 
367
367
  private
@@ -562,6 +562,7 @@ module PactBroker
562
562
  .join(:verifications, verifications_join)
563
563
  .join(:tags, tags_join, { table_alias: :provider_tags } )
564
564
  .where(Sequel[:latest_tagged_pact_publications][:provider_id] => provider_id)
565
+ .distinct
565
566
  .all
566
567
  hash[provider_tag] = head_pacts
567
568
  end
@@ -16,8 +16,10 @@ module PactBroker
16
16
  class MigrationTask < ::Rake::TaskLib
17
17
 
18
18
  attr_accessor :database_connection
19
+ attr_accessor :options
19
20
 
20
21
  def initialize &block
22
+ @options = {}
21
23
  rake_task &block
22
24
  end
23
25
 
@@ -27,12 +29,29 @@ module PactBroker
27
29
  desc "Run sequel migrations for pact broker database"
28
30
  task :migrate, [:target] do | t, args |
29
31
  require 'pact_broker/db/migrate'
32
+ require 'pact_broker/db/version'
33
+
30
34
  instance_eval(&block)
31
- options = {}
35
+
32
36
  if args[:target]
33
37
  options[:target] = args[:target].to_i
34
38
  end
39
+
40
+ if (logger = database_connection.loggers.first)
41
+ current_version = PactBroker::DB::Version.call(database_connection)
42
+ if options[:target]
43
+ logger.info "Migrating from schema version #{current_version} to #{options[:target]}"
44
+ else
45
+ logger.info "Migrating from schema version #{current_version} to latest"
46
+ end
47
+ end
48
+
35
49
  PactBroker::DB::Migrate.call(database_connection, options)
50
+
51
+ if logger
52
+ current_version = PactBroker::DB::Version.call(database_connection)
53
+ logger.info "Current schema version is now #{current_version}"
54
+ end
36
55
  end
37
56
  end
38
57
  end
@@ -204,6 +204,7 @@ module PactBroker
204
204
  params.delete(:comment)
205
205
  json_content = params[:json_content] || default_json_content
206
206
  pact_version_sha = params[:pact_version_sha] || generate_pact_version_sha(json_content)
207
+ pact_versions_count_before = PactBroker::Pacts::PactVersion.count
207
208
  @pact = PactBroker::Pacts::Repository.new.create(
208
209
  version_id: @consumer_version.id,
209
210
  consumer_id: @consumer.id,
@@ -211,8 +212,9 @@ module PactBroker
211
212
  pact_version_sha: pact_version_sha,
212
213
  json_content: prepare_json_content(json_content),
213
214
  )
215
+ pact_versions_count_after = PactBroker::Pacts::PactVersion.count
214
216
  set_created_at_if_set(params[:created_at], :pact_publications, id: @pact.id)
215
- set_created_at_if_set(params[:created_at], :pact_versions, sha: @pact.pact_version_sha)
217
+ set_created_at_if_set(params[:created_at], :pact_versions, sha: @pact.pact_version_sha) if pact_versions_count_after > pact_versions_count_before
216
218
  set_created_at_if_set(params[:created_at], :latest_pact_publication_ids_for_consumer_versions, consumer_version_id: @consumer_version.id)
217
219
  @pact = PactBroker::Pacts::PactPublication.find(id: @pact.id).to_domain
218
220
  self
@@ -248,7 +250,7 @@ module PactBroker
248
250
  events = event_params.collect{ |e| PactBroker::Webhooks::WebhookEvent.new(e) }
249
251
  template_params = { method: 'POST', url: 'http://example.org', headers: {'Content-Type' => 'application/json'}, username: params[:username], password: params[:password]}
250
252
  request = PactBroker::Webhooks::WebhookRequestTemplate.new(template_params.merge(params))
251
- @webhook = PactBroker::Webhooks::Repository.new.create uuid, PactBroker::Domain::Webhook.new(request: request, events: events), consumer, provider
253
+ @webhook = PactBroker::Webhooks::Repository.new.create uuid, PactBroker::Domain::Webhook.new(request: request, events: events, description: params[:description]), consumer, provider
252
254
  self
253
255
  end
254
256
 
@@ -424,7 +426,10 @@ module PactBroker
424
426
  def set_created_at_if_set created_at, table_name, selector
425
427
  date_to_set = created_at || @now
426
428
  if date_to_set
427
- Sequel::Model.db[table_name].where(selector.keys.first => selector.values.first).update(created_at: date_to_set)
429
+ Sequel::Model.db[table_name].where(selector).update(created_at: date_to_set)
430
+ if Sequel::Model.db.schema(table_name).any?{ |col| col.first == :updated_at }
431
+ Sequel::Model.db[table_name].where(selector.keys.first => selector.values.first).update(updated_at: date_to_set)
432
+ end
428
433
  end
429
434
  end
430
435
 
@@ -47,6 +47,7 @@ module PactBroker
47
47
  end
48
48
 
49
49
  map "/" do
50
+ use PathInfoFixer
50
51
  run PactBroker::UI::Controllers::Index
51
52
  end
52
53
  }
@@ -11,6 +11,9 @@ module PactBroker
11
11
  set :show_exceptions, ENV['RACK_ENV'] != 'production'
12
12
  set :dump_errors, false # The padrino logger logs these for us. If this is enabled we get duplicate logging.
13
13
 
14
+ def base_url
15
+ PactBroker.configuration.base_url || ''
16
+ end
14
17
  end
15
18
  end
16
19
  end
@@ -18,8 +18,8 @@ module PactBroker
18
18
  end
19
19
 
20
20
  get "/" do
21
- view_model = ViewDomain::IndexItems.new(pacticipant_service.find_index_items)
22
- haml 'clusters/show', locals: {relationships: view_model}
21
+ view_model = ViewDomain::IndexItems.new(pacticipant_service.find_index_items, base_url: base_url)
22
+ haml 'clusters/show', locals: {relationships: view_model, base_url: base_url}
23
23
  end
24
24
 
25
25
  end
@@ -13,9 +13,10 @@ module PactBroker
13
13
  pacticipant = pacticipant_service.find_pacticipant_by_name(params[:name])
14
14
  erb :'groups/show.html', {
15
15
  locals: {
16
- csv_path: "/groups/#{params[:name]}.csv",
16
+ csv_path: "#{base_url}/groups/#{params[:name]}.csv",
17
17
  pacticipant_name: params[:name],
18
- repository_url: pacticipant&.repository_url
18
+ repository_url: pacticipant&.repository_url,
19
+ base_url: base_url
19
20
  }
20
21
  }, {
21
22
  layout: 'layouts/main'
@@ -25,7 +25,7 @@ module PactBroker
25
25
 
26
26
  # TODO remove this code when verified
27
27
  options[:optimised] = true unless params[:optimised] == 'false'
28
- index_items = ViewDomain::IndexItems.new(index_service.find_index_items(options))
28
+ index_items = ViewDomain::IndexItems.new(index_service.find_index_items(options), base_url: base_url)
29
29
 
30
30
  page = tags ? :'index/show-with-tags' : :'index/show'
31
31
  locals = {
@@ -34,7 +34,8 @@ module PactBroker
34
34
  page_number: page_number,
35
35
  page_size: page_size,
36
36
  pagination_record_count: index_items.pagination_record_count,
37
- current_page_size: index_items.size
37
+ current_page_size: index_items.size,
38
+ base_url: base_url
38
39
  }
39
40
 
40
41
  haml page, {locals: locals, layout: :'layouts/main'}
@@ -3,6 +3,8 @@ require 'pact_broker/ui/view_models/matrix_lines'
3
3
  require 'pact_broker/matrix/unresolved_selector'
4
4
  require 'pact_broker/matrix/parse_query'
5
5
  require 'pact_broker/logging'
6
+ require 'pact_broker/api/pact_broker_urls'
7
+
6
8
  require 'haml'
7
9
 
8
10
  module PactBroker
@@ -19,7 +21,8 @@ module PactBroker
19
21
  lines: [],
20
22
  title: "The Matrix",
21
23
  selectors: create_selector_objects(selectors),
22
- options: create_options_model(options)
24
+ options: create_options_model(options),
25
+ base_url: base_url
23
26
  }
24
27
  begin
25
28
  if params[:q]
@@ -30,6 +33,7 @@ module PactBroker
30
33
  if errors.empty?
31
34
  lines = matrix_service.find(selectors, options)
32
35
  locals[:lines] = PactBroker::UI::ViewDomain::MatrixLines.new(lines)
36
+ locals[:badge_url] = matrix_badge_url(selectors, lines)
33
37
  else
34
38
  locals[:errors] = errors
35
39
  end
@@ -45,14 +49,16 @@ module PactBroker
45
49
  selectors = [ PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: params[:consumer_name]), PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: params[:provider_name]) ]
46
50
  options = {latestby: 'cvpv', limit: 100}
47
51
  lines = matrix_service.find(selectors, options)
48
- lines = PactBroker::UI::ViewDomain::MatrixLines.new(lines)
52
+ lines = PactBroker::UI::ViewDomain::MatrixLines.new(lines, base_url: base_url)
49
53
  locals = {
50
54
  lines: lines,
51
55
  title: "The Matrix",
52
56
  consumer_name: params[:consumer_name],
53
57
  provider_name: params[:provider_name],
54
58
  selectors: create_selector_objects(selectors),
55
- options: create_options_model(options)
59
+ options: create_options_model(options),
60
+ badge_url: nil,
61
+ base_url: base_url
56
62
  }
57
63
  haml :'matrix/show', {locals: locals, layout: :'layouts/main'}
58
64
  end
@@ -76,6 +82,16 @@ module PactBroker
76
82
  o.all_rows_checked = o.latestby.nil? ? 'checked' : nil
77
83
  o
78
84
  end
85
+
86
+ def matrix_badge_url(selectors, lines)
87
+ if lines.any? && selectors.size == 2 && selectors.all?{ | selector| selector.latest_for_pacticipant_and_tag? }
88
+ consumer_selector = selectors.find{ | selector| selector.pacticipant_name == lines.first.consumer_name }
89
+ provider_selector = selectors.find{ | selector| selector.pacticipant_name == lines.first.provider_name }
90
+ if consumer_selector && provider_selector
91
+ PactBroker::Api::PactBrokerUrls.matrix_badge_url_for_selectors(consumer_selector, provider_selector, base_url)
92
+ end
93
+ end
94
+ end
79
95
  end
80
96
  end
81
97
  end
@@ -7,12 +7,12 @@ module PactBroker
7
7
 
8
8
  extend self
9
9
 
10
- def group_url pacticipant_name
11
- "/groups/#{ERB::Util.url_encode(pacticipant_name)}"
10
+ def group_url pacticipant_name, base_url = ''
11
+ "#{base_url}/groups/#{ERB::Util.url_encode(pacticipant_name)}"
12
12
  end
13
13
 
14
- def matrix_url consumer_name, provider_name
15
- "/matrix/provider/#{ERB::Util.url_encode(provider_name)}/consumer/#{ERB::Util.url_encode(consumer_name)}"
14
+ def matrix_url consumer_name, provider_name, base_url = ''
15
+ "#{base_url}/matrix/provider/#{ERB::Util.url_encode(provider_name)}/consumer/#{ERB::Util.url_encode(consumer_name)}"
16
16
  end
17
17
  end
18
18
  end
@@ -11,8 +11,9 @@ module PactBroker
11
11
 
12
12
  include PactBroker::Api::PactBrokerUrls
13
13
 
14
- def initialize relationship
14
+ def initialize relationship, options = {}
15
15
  @relationship = relationship
16
+ @options = options
16
17
  end
17
18
 
18
19
  def consumer_name
@@ -48,23 +49,23 @@ module PactBroker
48
49
  end
49
50
 
50
51
  def consumer_group_url
51
- Helpers::URLHelper.group_url consumer_name
52
+ Helpers::URLHelper.group_url(consumer_name, base_url)
52
53
  end
53
54
 
54
55
  def provider_group_url
55
- Helpers::URLHelper.group_url provider_name
56
+ Helpers::URLHelper.group_url(provider_name, base_url)
56
57
  end
57
58
 
58
59
  def latest_pact_url
59
- "#{pactigration_base_url('', @relationship)}/latest"
60
+ "#{pactigration_base_url(base_url, @relationship)}/latest"
60
61
  end
61
62
 
62
63
  def pact_url
63
- PactBroker::Api::PactBrokerUrls.pact_url('', @relationship)
64
+ PactBroker::Api::PactBrokerUrls.pact_url(base_url, @relationship)
64
65
  end
65
66
 
66
67
  def pact_matrix_url
67
- Helpers::URLHelper.matrix_url consumer_name, provider_name
68
+ Helpers::URLHelper.matrix_url(consumer_name, provider_name, base_url)
68
69
  end
69
70
 
70
71
  def any_webhooks?
@@ -72,11 +73,11 @@ module PactBroker
72
73
  end
73
74
 
74
75
  def pact_versions_url
75
- PactBroker::Api::PactBrokerUrls.pact_versions_url(consumer_name, provider_name)
76
+ PactBroker::Api::PactBrokerUrls.pact_versions_url(consumer_name, provider_name, base_url)
76
77
  end
77
78
 
78
79
  def integration_url
79
- PactBroker::Api::PactBrokerUrls.integration_url(consumer_name, provider_name)
80
+ PactBroker::Api::PactBrokerUrls.integration_url(consumer_name, provider_name, base_url)
80
81
  end
81
82
 
82
83
  def webhook_label
@@ -114,11 +115,11 @@ module PactBroker
114
115
  def webhook_url
115
116
  url = case @relationship.webhook_status
116
117
  when :none
117
- PactBroker::Api::PactBrokerUrls.webhooks_for_consumer_and_provider_url @relationship.latest_pact.consumer, @relationship.latest_pact.provider
118
+ PactBroker::Api::PactBrokerUrls.webhooks_for_consumer_and_provider_url @relationship.latest_pact.consumer, @relationship.latest_pact.provider, base_url
118
119
  else
119
- PactBroker::Api::PactBrokerUrls.webhooks_status_url @relationship.latest_pact.consumer, @relationship.latest_pact.provider
120
+ PactBroker::Api::PactBrokerUrls.webhooks_status_url @relationship.latest_pact.consumer, @relationship.latest_pact.provider, base_url
120
121
  end
121
- "/hal-browser/browser.html##{url}"
122
+ PactBroker::Api::PactBrokerUrls.hal_browser_url(url, base_url)
122
123
  end
123
124
 
124
125
  def last_verified_date
@@ -181,6 +182,10 @@ module PactBroker
181
182
  version_number
182
183
  end
183
184
  end
185
+
186
+ def base_url
187
+ @options[:base_url]
188
+ end
184
189
  end
185
190
  end
186
191
  end
@@ -7,9 +7,9 @@ module PactBroker
7
7
 
8
8
  attr_reader :pagination_record_count
9
9
 
10
- def initialize index_items
10
+ def initialize index_items, options = {}
11
11
  # Why are we sorting twice!?
12
- @index_items = index_items.collect{ |index_item| IndexItem.new(index_item) }.sort
12
+ @index_items = index_items.collect{ |index_item| IndexItem.new(index_item, options) }.sort
13
13
  # until the feature flag is turned on
14
14
  @pagination_record_count = index_items.size
15
15
  @pagination_record_count = index_items.pagination_record_count if index_items.respond_to?(:pagination_record_count)
@@ -12,8 +12,9 @@ module PactBroker
12
12
  include PactBroker::Api::PactBrokerUrls
13
13
  include PactBroker::Messages
14
14
 
15
- def initialize line
15
+ def initialize line, options = {}
16
16
  @line = line
17
+ @options = options
17
18
  @overwritten = false # true if the pact was revised and this revision is no longer the latest
18
19
  end
19
20
 
@@ -22,7 +23,7 @@ module PactBroker
22
23
  end
23
24
 
24
25
  def provider_name_url
25
- hal_browser_url(pacticipant_url_from_params(pacticipant_name: provider_name))
26
+ hal_browser_url(pacticipant_url_from_params({ pacticipant_name: provider_name }, base_url), base_url)
26
27
  end
27
28
 
28
29
  def consumer_name
@@ -30,7 +31,7 @@ module PactBroker
30
31
  end
31
32
 
32
33
  def consumer_name_url
33
- hal_browser_url(pacticipant_url_from_params(pacticipant_name: consumer_name))
34
+ hal_browser_url(pacticipant_url_from_params({ pacticipant_name: consumer_name }, base_url), base_url)
34
35
  end
35
36
 
36
37
  def pact_version_sha
@@ -68,7 +69,7 @@ module PactBroker
68
69
 
69
70
  def consumer_version_number_url
70
71
  params = { pacticipant_name: consumer_name, version_number: consumer_version_number }
71
- hal_browser_url(version_url_from_params(params))
72
+ hal_browser_url(version_url_from_params(params, base_url), base_url)
72
73
  end
73
74
 
74
75
  def consumer_version_order
@@ -85,7 +86,7 @@ module PactBroker
85
86
 
86
87
  def provider_version_number_url
87
88
  params = { pacticipant_name: provider_name, version_number: provider_version_number }
88
- hal_browser_url(version_url_from_params(params))
89
+ hal_browser_url(version_url_from_params(params, base_url), base_url)
89
90
  end
90
91
 
91
92
  def provider_version_order
@@ -142,7 +143,7 @@ module PactBroker
142
143
  end
143
144
 
144
145
  def verification_status_url
145
- hal_browser_url(verification_url(self))
146
+ hal_browser_url(verification_url(self, base_url), base_url)
146
147
  end
147
148
 
148
149
  def pact_publication_date
@@ -150,7 +151,7 @@ module PactBroker
150
151
  end
151
152
 
152
153
  def pact_publication_date_url
153
- pact_url_from_params('', @line)
154
+ pact_url(base_url, @line)
154
155
  end
155
156
 
156
157
  def relative_date date
@@ -182,6 +183,10 @@ module PactBroker
182
183
  message("messages.matrix.pre_verified")
183
184
  end
184
185
  end
186
+
187
+ def base_url
188
+ @options[:base_url]
189
+ end
185
190
  end
186
191
  end
187
192
  end
@@ -5,9 +5,9 @@ module PactBroker
5
5
  module ViewDomain
6
6
  class MatrixLines < Array
7
7
 
8
- def initialize rows
8
+ def initialize rows, options = {}
9
9
  lines = rows.collect do | row |
10
- PactBroker::UI::ViewDomain::MatrixLine.new(row)
10
+ PactBroker::UI::ViewDomain::MatrixLine.new(row, options)
11
11
  end
12
12
  super(lines.sort)
13
13
  end
@@ -5,11 +5,11 @@
5
5
  <head>
6
6
  <meta charset="utf-8">
7
7
  <title>Network Graph</title>
8
- <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'/>
8
+ <link rel='shortcut icon' href='<%= base_url %>/favicon.ico' type='image/x-icon'/>
9
9
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
10
10
  <meta name="description" content="">
11
11
  <meta name="author" content="Duncan Alexander">
12
- <script type="text/javascript" src="/javascripts/d3.v3.js.pagespeed.ce.dFNRrGTALe.js"></script>
12
+ <script type="text/javascript" src="<%= base_url %>/javascripts/d3.v3.js.pagespeed.ce.dFNRrGTALe.js"></script>
13
13
  <style>
14
14
  body{
15
15
  font-family:"Helvetica Neue",Arial,sans-serif;
@@ -105,7 +105,7 @@ var relationshipPath = function(relationship, nodeLocations, pacticipants) {
105
105
 
106
106
  var latestPactUrl = function (consumerName, providerName) {
107
107
  //TODO send this with the relationship data
108
- return '/pacts/provider/' + providerName + '/consumer/' + consumerName + '/latest';
108
+ return '<%= base_url %>/pacts/provider/' + providerName + '/consumer/' + consumerName + '/latest';
109
109
  };
110
110
 
111
111
  var relationshipData = function(pacticipant, relationships) {