defra_ruby_mocks 2.3.3 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -75
  3. data/app/controllers/defra_ruby_mocks/govpay_controller.rb +23 -0
  4. data/app/services/defra_ruby_mocks/govpay_refund_details_service.rb +43 -0
  5. data/app/services/defra_ruby_mocks/govpay_request_refund_service.rb +27 -0
  6. data/config/routes.rb +10 -10
  7. data/lib/defra_ruby_mocks/configuration.rb +1 -1
  8. data/lib/defra_ruby_mocks/engine.rb +0 -1
  9. data/lib/defra_ruby_mocks/version.rb +1 -1
  10. data/spec/dummy/log/test.log +1256 -2285
  11. data/spec/examples.txt +68 -130
  12. data/spec/requests/govpay_spec.rb +44 -1
  13. data/spec/services/govpay_refund_details_service_spec.rb +58 -0
  14. data/spec/services/govpay_request_refund_service_spec.rb +31 -0
  15. metadata +8 -48
  16. data/app/controllers/defra_ruby_mocks/worldpay_controller.rb +0 -57
  17. data/app/services/defra_ruby_mocks/worldpay_payment_service.rb +0 -47
  18. data/app/services/defra_ruby_mocks/worldpay_refund_service.rb +0 -37
  19. data/app/services/defra_ruby_mocks/worldpay_request_handler_service.rb +0 -40
  20. data/app/services/defra_ruby_mocks/worldpay_resource_service.rb +0 -55
  21. data/app/services/defra_ruby_mocks/worldpay_response_service.rb +0 -119
  22. data/app/views/defra_ruby_mocks/worldpay/payment_request.xml.erb +0 -4
  23. data/app/views/defra_ruby_mocks/worldpay/refund_request.xml.erb +0 -4
  24. data/app/views/defra_ruby_mocks/worldpay/stuck.html.erb +0 -37
  25. data/lib/defra_ruby_mocks/unrecognised_worldpay_request_error.rb +0 -5
  26. data/spec/fixtures/files/worldpay/payment_request_invalid.xml +0 -6
  27. data/spec/fixtures/files/worldpay/payment_request_valid.xml +0 -30
  28. data/spec/fixtures/files/worldpay/refund_request_invalid.xml +0 -6
  29. data/spec/fixtures/files/worldpay/refund_request_valid.xml +0 -11
  30. data/spec/fixtures/files/worldpay/unrecognised_request.xml +0 -6
  31. data/spec/requests/worldpay_spec.rb +0 -163
  32. data/spec/services/worldpay_payment_service_spec.rb +0 -95
  33. data/spec/services/worldpay_refund_service_spec.rb +0 -68
  34. data/spec/services/worldpay_request_handler_service_spec.rb +0 -79
  35. data/spec/services/worldpay_resource_service_spec.rb +0 -120
  36. data/spec/services/worldpay_response_service_spec.rb +0 -280
data/spec/examples.txt CHANGED
@@ -1,130 +1,68 @@
1
- example_id | status | run_time |
2
- ------------------------------------------------------------------- | ------ | --------------- |
3
- ./spec/defra_ruby_mocks_spec.rb[1:1:1] | passed | 0.0021 seconds |
4
- ./spec/defra_ruby_mocks_spec.rb[1:2:1:1] | passed | 0.00011 seconds |
5
- ./spec/defra_ruby_mocks_spec.rb[1:2:2:1] | passed | 0.00012 seconds |
6
- ./spec/lib/configuration_spec.rb[1:1:1:1] | passed | 0.00007 seconds |
7
- ./spec/lib/configuration_spec.rb[1:1:2:1] | passed | 0.00008 seconds |
8
- ./spec/lib/configuration_spec.rb[1:1:3:1] | passed | 0.00008 seconds |
9
- ./spec/lib/configuration_spec.rb[1:1:4:1] | passed | 0.00091 seconds |
10
- ./spec/lib/configuration_spec.rb[1:2:1:1] | passed | 0.00007 seconds |
11
- ./spec/lib/configuration_spec.rb[1:2:2:1] | passed | 0.00008 seconds |
12
- ./spec/lib/configuration_spec.rb[1:2:3:1] | passed | 0.00008 seconds |
13
- ./spec/lib/configuration_spec.rb[1:2:4:1] | passed | 0.00007 seconds |
14
- ./spec/requests/company_spec.rb[1:1:1:1] | passed | 0.00172 seconds |
15
- ./spec/requests/company_spec.rb[1:1:2:1] | passed | 0.1464 seconds |
16
- ./spec/requests/company_spec.rb[1:1:3:1:1] | passed | 0.00602 seconds |
17
- ./spec/requests/company_spec.rb[1:1:3:2:1] | passed | 0.00515 seconds |
18
- ./spec/requests/company_spec.rb[1:2:1] | passed | 0.00241 seconds |
19
- ./spec/requests/govpay_spec.rb[1:1:1:1:1] | passed | 0.00286 seconds |
20
- ./spec/requests/govpay_spec.rb[1:1:1:1:2] | passed | 0.01265 seconds |
21
- ./spec/requests/govpay_spec.rb[1:1:1:2:1] | passed | 0.00163 seconds |
22
- ./spec/requests/govpay_spec.rb[1:1:2:1:1] | passed | 0.0029 seconds |
23
- ./spec/requests/govpay_spec.rb[1:1:2:2:1] | passed | 0.0027 seconds |
24
- ./spec/requests/govpay_spec.rb[1:2:1:1] | passed | 0.0009 seconds |
25
- ./spec/requests/govpay_spec.rb[1:2:2:1] | passed | 0.00364 seconds |
26
- ./spec/requests/govpay_spec.rb[1:2:3:1] | passed | 0.00382 seconds |
27
- ./spec/requests/officers_spec.rb[1:1:1] | passed | 0.00327 seconds |
28
- ./spec/requests/officers_spec.rb[1:2:1] | passed | 0.00161 seconds |
29
- ./spec/requests/worldpay_spec.rb[1:1:1:1:1:1] | passed | 0.00288 seconds |
30
- ./spec/requests/worldpay_spec.rb[1:1:1:1:2:1] | passed | 0.00211 seconds |
31
- ./spec/requests/worldpay_spec.rb[1:1:1:2:1:1] | passed | 0.00581 seconds |
32
- ./spec/requests/worldpay_spec.rb[1:1:2:1:1:1] | passed | 0.00368 seconds |
33
- ./spec/requests/worldpay_spec.rb[1:1:2:1:2:1] | passed | 0.0039 seconds |
34
- ./spec/requests/worldpay_spec.rb[1:1:2:2:1:1] | passed | 0.00236 seconds |
35
- ./spec/requests/worldpay_spec.rb[1:2:1:1] | passed | 0.00822 seconds |
36
- ./spec/requests/worldpay_spec.rb[1:2:2:1] | passed | 0.00117 seconds |
37
- ./spec/services/companies_house_service_spec.rb[1:1:1:1] | passed | 0.00008 seconds |
38
- ./spec/services/companies_house_service_spec.rb[1:1:2:1:1] | passed | 0.00006 seconds |
39
- ./spec/services/companies_house_service_spec.rb[1:1:2:1:2] | passed | 0.00006 seconds |
40
- ./spec/services/companies_house_service_spec.rb[1:1:2:2:1] | passed | 0.00006 seconds |
41
- ./spec/services/companies_house_service_spec.rb[1:1:2:2:2] | passed | 0.00007 seconds |
42
- ./spec/services/companies_house_service_spec.rb[1:1:2:3:1] | passed | 0.00007 seconds |
43
- ./spec/services/companies_house_service_spec.rb[1:1:2:3:2] | passed | 0.00008 seconds |
44
- ./spec/services/companies_house_service_spec.rb[1:1:2:4:1] | passed | 0.00006 seconds |
45
- ./spec/services/companies_house_service_spec.rb[1:1:2:4:2] | passed | 0.00007 seconds |
46
- ./spec/services/companies_house_service_spec.rb[1:1:2:5:1] | passed | 0.00007 seconds |
47
- ./spec/services/companies_house_service_spec.rb[1:1:2:5:2] | passed | 0.00008 seconds |
48
- ./spec/services/companies_house_service_spec.rb[1:1:2:6:1] | passed | 0.00006 seconds |
49
- ./spec/services/companies_house_service_spec.rb[1:1:2:6:2] | passed | 0.00008 seconds |
50
- ./spec/services/companies_house_service_spec.rb[1:1:2:7:1] | passed | 0.00006 seconds |
51
- ./spec/services/companies_house_service_spec.rb[1:1:2:7:2] | passed | 0.00006 seconds |
52
- ./spec/services/companies_house_service_spec.rb[1:1:2:8:1] | passed | 0.00006 seconds |
53
- ./spec/services/companies_house_service_spec.rb[1:1:2:8:2] | passed | 0.00007 seconds |
54
- ./spec/services/companies_house_service_spec.rb[1:1:2:9:1] | passed | 0.00007 seconds |
55
- ./spec/services/companies_house_service_spec.rb[1:1:2:9:2] | passed | 0.00006 seconds |
56
- ./spec/services/companies_house_service_spec.rb[1:1:3:1] | passed | 0.00006 seconds |
57
- ./spec/services/companies_house_service_spec.rb[1:1:3:2] | passed | 0.00009 seconds |
58
- ./spec/services/companies_house_service_spec.rb[1:1:3:3] | passed | 0.00006 seconds |
59
- ./spec/services/companies_house_service_spec.rb[1:1:3:4] | passed | 0.00007 seconds |
60
- ./spec/services/companies_house_service_spec.rb[1:1:4:1:1] | passed | 0.00007 seconds |
61
- ./spec/services/companies_house_service_spec.rb[1:1:4:2:1] | passed | 0.00008 seconds |
62
- ./spec/services/govpay_create_payment_service_spec.rb[1:1:1:1] | passed | 0.00279 seconds |
63
- ./spec/services/govpay_create_payment_service_spec.rb[1:1:1:2] | passed | 0.00266 seconds |
64
- ./spec/services/govpay_create_payment_service_spec.rb[1:1:1:3] | passed | 1.5 seconds |
65
- ./spec/services/govpay_create_payment_service_spec.rb[1:1:1:4] | passed | 0.00286 seconds |
66
- ./spec/services/govpay_get_payment_service_spec.rb[1:1:1:1] | passed | 0.00076 seconds |
67
- ./spec/services/govpay_get_payment_service_spec.rb[1:1:1:2] | passed | 0.00081 seconds |
68
- ./spec/services/worldpay_payment_service_spec.rb[1:1:1:1] | passed | 0.00012 seconds |
69
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:1] | passed | 0.00034 seconds |
70
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:2] | passed | 0.00032 seconds |
71
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:3] | passed | 0.00034 seconds |
72
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:4] | passed | 0.00045 seconds |
73
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:5:1] | passed | 0.0003 seconds |
74
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:5:2] | passed | 0.00031 seconds |
75
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:5:3] | passed | 0.0004 seconds |
76
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:6:1] | passed | 0.00034 seconds |
77
- ./spec/services/worldpay_payment_service_spec.rb[1:1:3:1] | passed | 0.00027 seconds |
78
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:1] | passed | 0.00122 seconds |
79
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:2] | passed | 0.00069 seconds |
80
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:3] | passed | 0.00029 seconds |
81
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:4] | passed | 0.00032 seconds |
82
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:5] | passed | 0.00038 seconds |
83
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:6] | passed | 0.00028 seconds |
84
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:7] | passed | 0.00028 seconds |
85
- ./spec/services/worldpay_refund_service_spec.rb[1:1:2:1] | passed | 0.00304 seconds |
86
- ./spec/services/worldpay_request_handler_service_spec.rb[1:1:1:1:1] | passed | 0.0006 seconds |
87
- ./spec/services/worldpay_request_handler_service_spec.rb[1:1:1:1:2] | passed | 0.00094 seconds |
88
- ./spec/services/worldpay_request_handler_service_spec.rb[1:1:1:2:1] | passed | 0.00047 seconds |
89
- ./spec/services/worldpay_request_handler_service_spec.rb[1:1:1:2:2] | passed | 0.00057 seconds |
90
- ./spec/services/worldpay_request_handler_service_spec.rb[1:1:1:3:1] | passed | 0.00052 seconds |
91
- ./spec/services/worldpay_resource_service_spec.rb[1:1:1:1] | passed | 0.00056 seconds |
92
- ./spec/services/worldpay_resource_service_spec.rb[1:1:1:2] | passed | 0.00049 seconds |
93
- ./spec/services/worldpay_resource_service_spec.rb[1:1:1:3] | passed | 0.00047 seconds |
94
- ./spec/services/worldpay_resource_service_spec.rb[1:1:1:4] | passed | 0.00047 seconds |
95
- ./spec/services/worldpay_resource_service_spec.rb[1:1:1:5:1] | passed | 0.00052 seconds |
96
- ./spec/services/worldpay_resource_service_spec.rb[1:1:2:1] | passed | 0.00061 seconds |
97
- ./spec/services/worldpay_resource_service_spec.rb[1:1:2:2] | passed | 0.00058 seconds |
98
- ./spec/services/worldpay_resource_service_spec.rb[1:1:2:3] | passed | 0.00059 seconds |
99
- ./spec/services/worldpay_resource_service_spec.rb[1:1:2:4] | passed | 0.00056 seconds |
100
- ./spec/services/worldpay_resource_service_spec.rb[1:1:3:1] | passed | 0.002 seconds |
101
- ./spec/services/worldpay_resource_service_spec.rb[1:1:4:1] | passed | 0.00051 seconds |
102
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:1] | passed | 0.00048 seconds |
103
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:2] | passed | 0.0005 seconds |
104
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:3:1] | passed | 0.00045 seconds |
105
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:3:2] | passed | 0.00051 seconds |
106
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:3:3:1] | passed | 0.00045 seconds |
107
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:4:1] | passed | 0.00047 seconds |
108
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:4:2] | passed | 0.00048 seconds |
109
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:5:1] | passed | 0.00047 seconds |
110
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:5:2] | passed | 0.00045 seconds |
111
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:6:1] | passed | 0.00048 seconds |
112
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:6:2] | passed | 0.0005 seconds |
113
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:7:1] | passed | 0.00047 seconds |
114
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:7:2] | passed | 0.00052 seconds |
115
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:8:1] | passed | 0.00047 seconds |
116
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:8:2] | passed | 0.00051 seconds |
117
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:1] | passed | 0.00047 seconds |
118
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:2] | passed | 0.01025 seconds |
119
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:3:1] | passed | 0.0005 seconds |
120
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:3:2] | passed | 0.00049 seconds |
121
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:4:1] | passed | 0.00047 seconds |
122
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:4:2] | passed | 0.00048 seconds |
123
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:5:1] | passed | 0.00046 seconds |
124
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:5:2] | passed | 0.0006 seconds |
125
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:6:1] | passed | 0.0005 seconds |
126
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:6:2] | passed | 0.00047 seconds |
127
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:7:1] | passed | 0.00051 seconds |
128
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:7:2] | passed | 0.00053 seconds |
129
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:8:1] | passed | 0.00049 seconds |
130
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:8:2] | passed | 0.00051 seconds |
1
+ example_id | status | run_time |
2
+ ---------------------------------------------------------------- | ------ | --------------- |
3
+ ./spec/defra_ruby_mocks_spec.rb[1:1:1] | passed | 0.00264 seconds |
4
+ ./spec/defra_ruby_mocks_spec.rb[1:2:1:1] | passed | 0.00153 seconds |
5
+ ./spec/defra_ruby_mocks_spec.rb[1:2:2:1] | passed | 0.00021 seconds |
6
+ ./spec/lib/configuration_spec.rb[1:1:1:1] | passed | 0.00016 seconds |
7
+ ./spec/lib/configuration_spec.rb[1:1:2:1] | passed | 0.00014 seconds |
8
+ ./spec/lib/configuration_spec.rb[1:1:3:1] | passed | 0.00011 seconds |
9
+ ./spec/lib/configuration_spec.rb[1:1:4:1] | passed | 0.00132 seconds |
10
+ ./spec/lib/configuration_spec.rb[1:2:1:1] | passed | 0.00015 seconds |
11
+ ./spec/lib/configuration_spec.rb[1:2:2:1] | passed | 0.00011 seconds |
12
+ ./spec/lib/configuration_spec.rb[1:2:3:1] | passed | 0.00012 seconds |
13
+ ./spec/lib/configuration_spec.rb[1:2:4:1] | passed | 0.00011 seconds |
14
+ ./spec/requests/company_spec.rb[1:1:1:1] | passed | 0.0037 seconds |
15
+ ./spec/requests/company_spec.rb[1:1:2:1] | passed | 0.00379 seconds |
16
+ ./spec/requests/company_spec.rb[1:1:3:1:1] | passed | 0.00573 seconds |
17
+ ./spec/requests/company_spec.rb[1:1:3:2:1] | passed | 0.02066 seconds |
18
+ ./spec/requests/company_spec.rb[1:2:1] | passed | 0.0021 seconds |
19
+ ./spec/requests/govpay_spec.rb[1:1:1:1:1] | passed | 0.00464 seconds |
20
+ ./spec/requests/govpay_spec.rb[1:1:1:1:2] | passed | 0.01777 seconds |
21
+ ./spec/requests/govpay_spec.rb[1:1:1:2:1] | passed | 0.00307 seconds |
22
+ ./spec/requests/govpay_spec.rb[1:1:2:1:1] | passed | 0.0447 seconds |
23
+ ./spec/requests/govpay_spec.rb[1:1:2:2:1] | passed | 0.00415 seconds |
24
+ ./spec/requests/govpay_spec.rb[1:1:3:1:1] | passed | 0.00269 seconds |
25
+ ./spec/requests/govpay_spec.rb[1:1:3:2:1] | passed | 0.0036 seconds |
26
+ ./spec/requests/govpay_spec.rb[1:1:4:1:1] | passed | 0.00626 seconds |
27
+ ./spec/requests/govpay_spec.rb[1:2:1:1] | passed | 0.00168 seconds |
28
+ ./spec/requests/govpay_spec.rb[1:2:2:1] | passed | 0.00723 seconds |
29
+ ./spec/requests/govpay_spec.rb[1:2:3:1] | passed | 0.00976 seconds |
30
+ ./spec/requests/officers_spec.rb[1:1:1] | passed | 0.00514 seconds |
31
+ ./spec/requests/officers_spec.rb[1:2:1] | passed | 0.0021 seconds |
32
+ ./spec/services/companies_house_service_spec.rb[1:1:1:1] | passed | 0.00016 seconds |
33
+ ./spec/services/companies_house_service_spec.rb[1:1:2:1:1] | passed | 0.00011 seconds |
34
+ ./spec/services/companies_house_service_spec.rb[1:1:2:1:2] | passed | 0.00015 seconds |
35
+ ./spec/services/companies_house_service_spec.rb[1:1:2:2:1] | passed | 0.00014 seconds |
36
+ ./spec/services/companies_house_service_spec.rb[1:1:2:2:2] | passed | 0.00012 seconds |
37
+ ./spec/services/companies_house_service_spec.rb[1:1:2:3:1] | passed | 0.00017 seconds |
38
+ ./spec/services/companies_house_service_spec.rb[1:1:2:3:2] | passed | 0.00012 seconds |
39
+ ./spec/services/companies_house_service_spec.rb[1:1:2:4:1] | passed | 0.00012 seconds |
40
+ ./spec/services/companies_house_service_spec.rb[1:1:2:4:2] | passed | 0.00012 seconds |
41
+ ./spec/services/companies_house_service_spec.rb[1:1:2:5:1] | passed | 0.00013 seconds |
42
+ ./spec/services/companies_house_service_spec.rb[1:1:2:5:2] | passed | 0.00014 seconds |
43
+ ./spec/services/companies_house_service_spec.rb[1:1:2:6:1] | passed | 0.00013 seconds |
44
+ ./spec/services/companies_house_service_spec.rb[1:1:2:6:2] | passed | 0.00012 seconds |
45
+ ./spec/services/companies_house_service_spec.rb[1:1:2:7:1] | passed | 0.00012 seconds |
46
+ ./spec/services/companies_house_service_spec.rb[1:1:2:7:2] | passed | 0.00017 seconds |
47
+ ./spec/services/companies_house_service_spec.rb[1:1:2:8:1] | passed | 0.00012 seconds |
48
+ ./spec/services/companies_house_service_spec.rb[1:1:2:8:2] | passed | 0.00015 seconds |
49
+ ./spec/services/companies_house_service_spec.rb[1:1:2:9:1] | passed | 0.00016 seconds |
50
+ ./spec/services/companies_house_service_spec.rb[1:1:2:9:2] | passed | 0.00017 seconds |
51
+ ./spec/services/companies_house_service_spec.rb[1:1:3:1] | passed | 0.00012 seconds |
52
+ ./spec/services/companies_house_service_spec.rb[1:1:3:2] | passed | 0.00011 seconds |
53
+ ./spec/services/companies_house_service_spec.rb[1:1:3:3] | passed | 0.00013 seconds |
54
+ ./spec/services/companies_house_service_spec.rb[1:1:3:4] | passed | 0.00011 seconds |
55
+ ./spec/services/companies_house_service_spec.rb[1:1:4:1:1] | passed | 0.00013 seconds |
56
+ ./spec/services/companies_house_service_spec.rb[1:1:4:2:1] | passed | 0.00016 seconds |
57
+ ./spec/services/govpay_create_payment_service_spec.rb[1:1:1:1] | passed | 2.29 seconds |
58
+ ./spec/services/govpay_create_payment_service_spec.rb[1:1:1:2] | passed | 0.00453 seconds |
59
+ ./spec/services/govpay_create_payment_service_spec.rb[1:1:1:3] | passed | 0.00433 seconds |
60
+ ./spec/services/govpay_create_payment_service_spec.rb[1:1:1:4] | passed | 0.00429 seconds |
61
+ ./spec/services/govpay_get_payment_service_spec.rb[1:1:1:1] | passed | 0.00109 seconds |
62
+ ./spec/services/govpay_get_payment_service_spec.rb[1:1:1:2] | passed | 0.00128 seconds |
63
+ ./spec/services/govpay_refund_details_service_spec.rb[1:1:1:1] | passed | 0.0016 seconds |
64
+ ./spec/services/govpay_refund_details_service_spec.rb[1:1:2:1:1] | passed | 0.00264 seconds |
65
+ ./spec/services/govpay_refund_details_service_spec.rb[1:1:2:2:1] | passed | 0.00247 seconds |
66
+ ./spec/services/govpay_refund_details_service_spec.rb[1:1:2:3:1] | passed | 0.003 seconds |
67
+ ./spec/services/govpay_request_refund_service_spec.rb[1:1:1:1] | passed | 0.00116 seconds |
68
+ ./spec/services/govpay_request_refund_service_spec.rb[1:1:1:2] | passed | 0.17665 seconds |
@@ -50,7 +50,7 @@ module DefraRubyMocks
50
50
  context "when the request is missing a mandatory parameter" do
51
51
  before { payment_request[:amount] = nil }
52
52
 
53
- it "returns a HTTP 500 responseß" do
53
+ it "returns a HTTP 500 response" do
54
54
  post path, params: payment_request.as_json
55
55
 
56
56
  expect(response.code).to eq "500"
@@ -93,6 +93,49 @@ module DefraRubyMocks
93
93
  end
94
94
  end
95
95
  end
96
+
97
+ describe "#create_refund" do
98
+ let(:payment_id) { "12345678901234567890123456" }
99
+ let(:path) { "/defra_ruby_mocks/govpay/v1/payments/#{payment_id}/refunds" }
100
+ let(:refund_request) do
101
+ {
102
+ "amount": 2000,
103
+ "refund_amount_available": 5000
104
+ }
105
+ end
106
+
107
+ context "when the request is missing a mandatory parameter" do
108
+ before { refund_request[:refund_amount_available] = nil }
109
+
110
+ it "returns a HTTP 500 response" do
111
+ post path, params: refund_request.as_json
112
+
113
+ expect(response.code).to eq "500"
114
+ end
115
+ end
116
+
117
+ context "with a valid request" do
118
+ it "returns a valid success response" do
119
+ post path, params: refund_request.as_json
120
+
121
+ expect(response.code).to eq "200"
122
+ end
123
+ end
124
+ end
125
+
126
+ describe "#refund_details" do
127
+ let(:payment_id) { "12345678901234567890123456" }
128
+ let(:refund_id) { "j6se0f2o427g28g8yg3u3i" }
129
+ let(:path) { "/defra_ruby_mocks/govpay/v1/payments/#{payment_id}/refunds/#{refund_id}" }
130
+
131
+ context "with a valid request" do
132
+ it "returns a valid success response" do
133
+ get path
134
+
135
+ expect(response.code).to eq "200"
136
+ end
137
+ end
138
+ end
96
139
  end
97
140
 
98
141
  context "when mocks are disabled" do
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails_helper"
4
+
5
+ module DefraRubyMocks
6
+
7
+ RSpec.describe GovpayRefundDetailsService do
8
+ let(:payment_id) { SecureRandom.hex(26) }
9
+ let(:refund_id) { SecureRandom.hex(22) }
10
+
11
+ before { Helpers::Configuration.prep_for_tests }
12
+
13
+ # Note that the service currently supports only success responses.
14
+ describe ".run" do
15
+ let(:create_request_time) { Time.zone.now }
16
+ let(:submitted_success_lag) { "10" }
17
+
18
+ subject { described_class.run(payment_id: payment_id, refund_id: refund_id).deep_symbolize_keys }
19
+
20
+ # the service shoud return "submitted" for up to GOVPAY_REFUND_SUBMITTED_SUCCESS_LAG seconds, "success" thereafter
21
+ before do
22
+ Timecop.freeze(create_request_time)
23
+ allow(ENV).to receive(:fetch).with("GOVPAY_REFUND_SUBMITTED_SUCCESS_LAG", any_args).and_return(submitted_success_lag)
24
+ FileUtils.rm_rf("#{Dir.tmpdir}/govpay_request_refund_service_last_run_time")
25
+ end
26
+
27
+ context "when no refund timestamp file exists" do
28
+ it { expect(subject[:status]).to eq "success" }
29
+ end
30
+
31
+ context "when a refund has been requested" do
32
+ before do
33
+ GovpayRequestRefundService.run(payment_id: payment_id, amount: 100, refund_amount_available: 100).deep_symbolize_keys
34
+ end
35
+
36
+ context "when less than 10 seconds has elapsed since the last create request" do
37
+ before { Timecop.freeze(create_request_time + (submitted_success_lag.to_i - 8).seconds) }
38
+
39
+ it { expect(subject[:status]).to eq "submitted" }
40
+ end
41
+
42
+ context "when 10 seconds has elapsed since the last create request" do
43
+ before { Timecop.freeze(create_request_time + (submitted_success_lag.to_i + 8).seconds) }
44
+
45
+ it { expect(subject[:status]).to eq "success" }
46
+ end
47
+
48
+ context "when GOVPAY_REFUND_SUBMITTED_SUCCESS_LAG is not set" do
49
+ let(:submitted_success_lag) { nil }
50
+
51
+ before { Timecop.freeze(create_request_time + 1.hour) }
52
+
53
+ it { expect(subject[:status]).to eq "success" }
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails_helper"
4
+
5
+ module DefraRubyMocks
6
+
7
+ RSpec.describe GovpayRequestRefundService do
8
+ let(:payment_id) { SecureRandom.hex(26) }
9
+ let(:amount) { 2000 }
10
+ let(:refund_amount_available) { amount }
11
+
12
+ before { Helpers::Configuration.prep_for_tests }
13
+
14
+ # Note that the service currently supports only "submitted" responses.
15
+ describe ".run" do
16
+
17
+ subject { described_class.run(payment_id: payment_id, amount: amount, refund_amount_available: refund_amount_available).deep_symbolize_keys }
18
+
19
+ context "when the refund has been successfully submitted" do
20
+
21
+ it "returns a response with the expected status" do
22
+ expect(subject[:status]).to eq("submitted")
23
+ end
24
+
25
+ it "returns a response with the expected amount" do
26
+ expect(subject[:amount]).to eq(amount)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: defra_ruby_mocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.3
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Defra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-30 00:00:00.000000000 Z
11
+ date: 2023-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.7.2
41
- - !ruby/object:Gem::Dependency
42
- name: nokogiri
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: github_changelog_generator
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -150,31 +136,23 @@ files:
150
136
  - app/controllers/defra_ruby_mocks/application_controller.rb
151
137
  - app/controllers/defra_ruby_mocks/company_controller.rb
152
138
  - app/controllers/defra_ruby_mocks/govpay_controller.rb
153
- - app/controllers/defra_ruby_mocks/worldpay_controller.rb
154
139
  - app/jobs/defra_ruby_mocks/application_job.rb
155
140
  - app/jobs/defra_ruby_mocks/govpay_payment_callback_job.rb
156
141
  - app/services/defra_ruby_mocks/base_service.rb
157
142
  - app/services/defra_ruby_mocks/companies_house_service.rb
158
143
  - app/services/defra_ruby_mocks/govpay_create_payment_service.rb
159
144
  - app/services/defra_ruby_mocks/govpay_get_payment_service.rb
160
- - app/services/defra_ruby_mocks/worldpay_payment_service.rb
161
- - app/services/defra_ruby_mocks/worldpay_refund_service.rb
162
- - app/services/defra_ruby_mocks/worldpay_request_handler_service.rb
163
- - app/services/defra_ruby_mocks/worldpay_resource_service.rb
164
- - app/services/defra_ruby_mocks/worldpay_response_service.rb
145
+ - app/services/defra_ruby_mocks/govpay_refund_details_service.rb
146
+ - app/services/defra_ruby_mocks/govpay_request_refund_service.rb
165
147
  - app/views/defra_ruby_mocks/company/not_found.json.erb
166
148
  - app/views/defra_ruby_mocks/company/officers.json.erb
167
149
  - app/views/defra_ruby_mocks/company/show.json.erb
168
- - app/views/defra_ruby_mocks/worldpay/payment_request.xml.erb
169
- - app/views/defra_ruby_mocks/worldpay/refund_request.xml.erb
170
- - app/views/defra_ruby_mocks/worldpay/stuck.html.erb
171
150
  - config/routes.rb
172
151
  - lib/defra_ruby_mocks.rb
173
152
  - lib/defra_ruby_mocks/configuration.rb
174
153
  - lib/defra_ruby_mocks/engine.rb
175
154
  - lib/defra_ruby_mocks/invalid_config_error.rb
176
155
  - lib/defra_ruby_mocks/missing_resource_error.rb
177
- - lib/defra_ruby_mocks/unrecognised_worldpay_request_error.rb
178
156
  - lib/defra_ruby_mocks/version.rb
179
157
  - lib/tasks/changelog.rake
180
158
  - lib/tasks/defra_ruby_mocks_tasks.rake
@@ -224,25 +202,16 @@ files:
224
202
  - spec/fixtures/files/govpay/get_payment_response_not_found.json
225
203
  - spec/fixtures/files/govpay/get_payment_response_submitted.json
226
204
  - spec/fixtures/files/govpay/get_payment_response_success.json
227
- - spec/fixtures/files/worldpay/payment_request_invalid.xml
228
- - spec/fixtures/files/worldpay/payment_request_valid.xml
229
- - spec/fixtures/files/worldpay/refund_request_invalid.xml
230
- - spec/fixtures/files/worldpay/refund_request_valid.xml
231
- - spec/fixtures/files/worldpay/unrecognised_request.xml
232
205
  - spec/lib/configuration_spec.rb
233
206
  - spec/rails_helper.rb
234
207
  - spec/requests/company_spec.rb
235
208
  - spec/requests/govpay_spec.rb
236
209
  - spec/requests/officers_spec.rb
237
- - spec/requests/worldpay_spec.rb
238
210
  - spec/services/companies_house_service_spec.rb
239
211
  - spec/services/govpay_create_payment_service_spec.rb
240
212
  - spec/services/govpay_get_payment_service_spec.rb
241
- - spec/services/worldpay_payment_service_spec.rb
242
- - spec/services/worldpay_refund_service_spec.rb
243
- - spec/services/worldpay_request_handler_service_spec.rb
244
- - spec/services/worldpay_resource_service_spec.rb
245
- - spec/services/worldpay_response_service_spec.rb
213
+ - spec/services/govpay_refund_details_service_spec.rb
214
+ - spec/services/govpay_request_refund_service_spec.rb
246
215
  - spec/spec_helper.rb
247
216
  - spec/support/helpers/configuration.rb
248
217
  - spec/support/helpers/helpers.rb
@@ -314,7 +283,6 @@ test_files:
314
283
  - spec/defra_ruby_mocks_spec.rb
315
284
  - spec/requests/govpay_spec.rb
316
285
  - spec/requests/company_spec.rb
317
- - spec/requests/worldpay_spec.rb
318
286
  - spec/requests/officers_spec.rb
319
287
  - spec/support/simplecov.rb
320
288
  - spec/support/pry.rb
@@ -323,11 +291,6 @@ test_files:
323
291
  - spec/support/helpers/configuration.rb
324
292
  - spec/support/helpers/waste_carriers_engine.rb
325
293
  - spec/lib/configuration_spec.rb
326
- - spec/fixtures/files/worldpay/unrecognised_request.xml
327
- - spec/fixtures/files/worldpay/payment_request_invalid.xml
328
- - spec/fixtures/files/worldpay/refund_request_valid.xml
329
- - spec/fixtures/files/worldpay/payment_request_valid.xml
330
- - spec/fixtures/files/worldpay/refund_request_invalid.xml
331
294
  - spec/fixtures/files/govpay/get_payment_response_submitted.json
332
295
  - spec/fixtures/files/govpay/get_payment_response_not_found.json
333
296
  - spec/fixtures/files/govpay/create_payment_created_response.json
@@ -339,10 +302,7 @@ test_files:
339
302
  - spec/fixtures/files/govpay/get_payment_response_error.json
340
303
  - spec/rails_helper.rb
341
304
  - spec/services/govpay_get_payment_service_spec.rb
342
- - spec/services/worldpay_response_service_spec.rb
343
- - spec/services/worldpay_resource_service_spec.rb
305
+ - spec/services/govpay_request_refund_service_spec.rb
344
306
  - spec/services/companies_house_service_spec.rb
345
- - spec/services/worldpay_payment_service_spec.rb
346
- - spec/services/worldpay_refund_service_spec.rb
347
- - spec/services/worldpay_request_handler_service_spec.rb
307
+ - spec/services/govpay_refund_details_service_spec.rb
348
308
  - spec/services/govpay_create_payment_service_spec.rb
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DefraRubyMocks
4
- class WorldpayController < ::DefraRubyMocks::ApplicationController
5
- protect_from_forgery with: :exception, except: [:payments_service]
6
-
7
- before_action :set_default_response_format
8
-
9
- def payments_service
10
- @values = WorldpayRequestHandlerService.run(convert_request_body_to_xml)
11
-
12
- render_payment_response if @values[:request_type] == :payment
13
- render_refund_response if @values[:request_type] == :refund
14
- rescue StandardError => e
15
- Rails.logger.error("MOCKS: Worldpay payments service error: #{e.message}")
16
- head 500
17
- end
18
-
19
- def dispatcher
20
- @response = WorldpayResponseService.run(
21
- success_url: params[:successURL],
22
- failure_url: params[:failureURL],
23
- pending_url: params[:pendingURL],
24
- cancel_url: params[:cancelURL],
25
- error_url: params[:errorURL]
26
- )
27
-
28
- if @response.status == :STUCK
29
- render formats: :html, action: "stuck", layout: false
30
- else
31
- redirect_to @response.url
32
- end
33
- rescue StandardError => e
34
- Rails.logger.error("MOCKS: Worldpay dispatcher error: #{e.message}")
35
- head 500
36
- end
37
-
38
- private
39
-
40
- def set_default_response_format
41
- request.format = :xml
42
- end
43
-
44
- def convert_request_body_to_xml
45
- Nokogiri::XML(request.body.read)
46
- end
47
-
48
- def render_payment_response
49
- render "defra_ruby_mocks/worldpay/payment_request"
50
- end
51
-
52
- def render_refund_response
53
- render "defra_ruby_mocks/worldpay/refund_request"
54
- end
55
-
56
- end
57
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DefraRubyMocks
4
- class WorldpayPaymentService < BaseService
5
- def run(merchant_code:, xml:)
6
- check_config
7
-
8
- @merchant_code = merchant_code
9
- @order_code = extract_order_code(xml)
10
-
11
- {
12
- merchant_code: @merchant_code,
13
- order_code: @order_code,
14
- id: generate_id,
15
- url: generate_url
16
- }
17
- end
18
-
19
- private
20
-
21
- def check_config
22
- domain = DefraRubyMocks.configuration.worldpay_domain
23
-
24
- raise InvalidConfigError, :worldpay_domain if domain.blank?
25
- end
26
-
27
- def extract_order_code(xml)
28
- order = xml.at_xpath("//order")
29
- order.attribute("orderCode").text
30
- end
31
-
32
- def generate_id
33
- # Worldpay seems to generate 10 digit numbers for all its ID's. So we
34
- # replicate that here with this.
35
- # https://stackoverflow.com/a/31043825
36
- rand(1e9...1e10).to_i.to_s
37
- end
38
-
39
- def generate_url
40
- "#{base_url}?OrderKey=#{@merchant_code}%5E#{@order_code}"
41
- end
42
-
43
- def base_url
44
- File.join(DefraRubyMocks.configuration.worldpay_domain, "/worldpay/dispatcher")
45
- end
46
- end
47
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DefraRubyMocks
4
- class WorldpayRefundService < BaseService
5
- def run(merchant_code:, xml:)
6
- {
7
- merchant_code: merchant_code,
8
- order_code: extract_order_code(xml),
9
- refund_value: extract_refund_value(xml),
10
- currency_code: extract_currency_code(xml),
11
- exponent: extract_exponent(xml)
12
- }
13
- end
14
-
15
- private
16
-
17
- def extract_order_code(xml)
18
- order_modification = xml.at_xpath("//orderModification")
19
- order_modification.attribute("orderCode").text
20
- end
21
-
22
- def extract_refund_value(xml)
23
- amount = xml.at_xpath("//amount")
24
- amount.attribute("value").text
25
- end
26
-
27
- def extract_currency_code(xml)
28
- amount = xml.at_xpath("//amount")
29
- amount.attribute("currencyCode").text
30
- end
31
-
32
- def extract_exponent(xml)
33
- amount = xml.at_xpath("//amount")
34
- amount.attribute("exponent").text
35
- end
36
- end
37
- end