@@ -27,20 +27,20 @@ def create(opts = {})
27
27
28
28
it 'results in a 204 if the hook is accepted' do
29
29
create
30
- last_response . status . should be == 204
30
+ expect ( last_response . status ) . to be ( 204 )
31
31
end
32
32
33
33
describe 'without a payload' do
34
34
let ( :payload ) { nil }
35
35
it 'does not accept a hook' do
36
36
create
37
- last_response . status . should be == 422
37
+ expect ( last_response . status ) . to be ( 422 )
38
38
end
39
39
end
40
40
41
41
it 'returns 200 when checking if the app is still running' do
42
42
get '/uptime'
43
- last_response . status . should be == 200
43
+ expect ( last_response . status ) . to be ( 200 )
44
44
end
45
45
46
46
it "should push the message to sidekiq" do
@@ -55,60 +55,60 @@ def create(opts = {})
55
55
56
56
context "with valid_ips provided" do
57
57
before do
58
- described_class . any_instance . stub ( :valid_ips ) . and_return ( [ '1.2.3.4' ] )
58
+ allow_any_instance_of ( described_class ) . to receive ( :valid_ips ) . and_return ( [ '1.2.3.4' ] )
59
59
end
60
60
61
61
context "when ip_validation is turned off" do
62
62
it 'accepts a request from an invalid IP' do
63
- described_class . any_instance . should_receive ( :report_ip_validity )
63
+ expect_any_instance_of ( described_class ) . to receive ( :report_ip_validity )
64
64
create headers : { 'REMOTE_ADDR' => '1.2.3.1' }
65
- last_response . status . should be == 204
65
+ expect ( last_response . status ) . to be ( 204 )
66
66
end
67
67
end
68
68
69
69
context "when ip_validation is turned on" do
70
70
before do
71
- described_class . any_instance . stub ( :ip_validation? ) . and_return ( true )
71
+ allow_any_instance_of ( described_class ) . to receive ( :ip_validation? ) . and_return ( true )
72
72
end
73
73
74
74
it 'accepts a request from valid IP' do
75
75
create headers : { 'REMOTE_ADDR' => '1.2.3.4' }
76
- last_response . status . should be == 204
76
+ expect ( last_response . status ) . to be ( 204 )
77
77
end
78
78
79
79
it 'rejects a request without a valid IP' do
80
80
create headers : { 'REMOTE_ADDR' => '1.1.1.1' }
81
- last_response . status . should be == 403
81
+ expect ( last_response . status ) . to be ( 403 )
82
82
end
83
83
end
84
84
end
85
85
86
86
context 'with valid_ips provided as a range' do
87
87
before do
88
- described_class . any_instance . stub ( :valid_ips ) . and_return ( [ '1.1.1.0/30' ] )
89
- described_class . any_instance . stub ( :ip_validation? ) . and_return ( true )
88
+ allow_any_instance_of ( described_class ) . to receive ( :valid_ips ) . and_return ( [ '1.1.1.0/30' ] )
89
+ allow_any_instance_of ( described_class ) . to receive ( :ip_validation? ) . and_return ( true )
90
90
end
91
91
92
92
it 'accepts a request from valid IP' do
93
93
create headers : { 'REMOTE_ADDR' => '1.1.1.0' }
94
- last_response . status . should be == 204
94
+ expect ( last_response . status ) . to be ( 204 )
95
95
96
96
create headers : { 'REMOTE_ADDR' => '1.1.1.1' }
97
- last_response . status . should be == 204
97
+ expect ( last_response . status ) . to be ( 204 )
98
98
99
99
create headers : { 'REMOTE_ADDR' => '1.1.1.2' }
100
- last_response . status . should be == 204
100
+ expect ( last_response . status ) . to be ( 204 )
101
101
102
102
create headers : { 'REMOTE_ADDR' => '1.1.1.3' }
103
- last_response . status . should be == 204
103
+ expect ( last_response . status ) . to be ( 204 )
104
104
end
105
105
106
106
it 'rejects a request without a valid IP' do
107
107
create headers : { 'REMOTE_ADDR' => '1.1.1.4' }
108
- last_response . status . should be == 403
108
+ expect ( last_response . status ) . to be ( 403 )
109
109
110
110
create headers : { 'REMOTE_ADDR' => '1.1.1.10' }
111
- last_response . status . should be == 403
111
+ expect ( last_response . status ) . to be ( 403 )
112
112
end
113
113
end
114
114
end
0 commit comments