@@ -4,10 +4,14 @@ module PactBroker
4
4
module Integrations
5
5
describe Integration do
6
6
before do
7
- td . create_pact_with_hierarchy ( "Foo" , "1" , "Bar" )
7
+ td . set_now ( DateTime . new ( 2019 , 1 , 1 ) )
8
+ . create_pact_with_hierarchy ( "Foo" , "1" , "Bar" )
9
+ . set_now ( DateTime . new ( 2019 , 1 , 2 ) )
8
10
. create_consumer_version ( "2" )
9
11
. create_pact
12
+ . set_now ( DateTime . new ( 2019 , 1 , 3 ) )
10
13
. create_verification ( provider_version : "3" )
14
+ . set_now ( DateTime . new ( 2019 , 1 , 4 ) )
11
15
. create_verification ( provider_version : "4" , number : 2 )
12
16
end
13
17
@@ -24,6 +28,28 @@ module Integrations
24
28
it "has a verification status" do
25
29
expect ( Integration . first . verification_status_for_latest_pact ) . to be_instance_of ( PactBroker ::Verifications ::Status )
26
30
end
31
+
32
+ describe "latest_pact_or_verification_publication_date" do
33
+ context "when the last publication is a verification" do
34
+ it "returns the verification execution date" do
35
+ date = td . in_utc { DateTime . new ( 2019 , 1 , 4 ) }
36
+ expect ( Integration . first . latest_pact_or_verification_publication_date ) . to eq date
37
+ end
38
+ end
39
+
40
+ context "when the last publication is a pact" do
41
+ before do
42
+ td . set_now ( DateTime . new ( 2019 , 1 , 5 ) )
43
+ . create_consumer_version ( "3" )
44
+ . create_pact
45
+ end
46
+
47
+ it "returns the pact publication date" do
48
+ date = td . in_utc { DateTime . new ( 2019 , 1 , 5 ) }
49
+ expect ( Integration . first . latest_pact_or_verification_publication_date ) . to eq date
50
+ end
51
+ end
52
+ end
27
53
end
28
54
end
29
55
end
0 commit comments