1
1
require 'pact_broker/api/decorators/dashboard_decorator'
2
2
require 'pact_broker/domain/index_item'
3
3
4
+ ORIGINAL_TZ = ENV [ 'TZ' ]
5
+
4
6
module PactBroker
5
7
module Api
6
8
module Decorators
@@ -26,14 +28,24 @@ module Decorators
26
28
end
27
29
let ( :consumer ) { instance_double ( 'PactBroker::Domain::Pacticipant' , name : 'Foo' ) }
28
30
let ( :provider ) { instance_double ( 'PactBroker::Domain::Pacticipant' , name : 'Bar' ) }
29
- let ( :pact ) { instance_double ( 'PactBroker::Domain::Pact' , created_at : DateTime . new ( 2018 ) ) }
30
- let ( :verification ) { instance_double ( 'PactBroker::Domain::Verification' , success : true , created_at : DateTime . new ( 2018 ) ) }
31
+ let ( :pact ) { instance_double ( 'PactBroker::Domain::Pact' , created_at : created_at ) }
32
+ let ( :verification ) { instance_double ( 'PactBroker::Domain::Verification' , success : true , created_at : created_at ) }
31
33
let ( :consumer_version ) { instance_double ( 'PactBroker::Domain::Version' , number : '1' , pacticipant : consumer ) }
32
34
let ( :provider_version ) { instance_double ( 'PactBroker::Domain::Version' , number : '2' , pacticipant : provider ) }
33
- let ( :last_webhook_execution_date ) { Date . new ( 2018 ) }
35
+ let ( :last_webhook_execution_date ) { created_at }
34
36
let ( :base_url ) { 'http://example.org' }
35
37
let ( :options ) { { user_options : { base_url : base_url } } }
36
38
let ( :dashboard_json ) { DashboardDecorator . new ( [ index_item ] ) . to_json ( options ) }
39
+ let ( :created_at ) { in_utc { DateTime . new ( 2018 ) } }
40
+
41
+ def in_utc
42
+ begin
43
+ ENV [ 'TZ' ] = 'UTC'
44
+ yield
45
+ ensure
46
+ ENV [ 'TZ' ] = ORIGINAL_TZ
47
+ end
48
+ end
37
49
38
50
before do
39
51
allow_any_instance_of ( DashboardDecorator ) . to receive ( :pact_url ) . with ( base_url , pact ) . and_return ( 'pact_url' )
0 commit comments