web47core 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{lib/app → app}/assets/stylesheets/status.sass +0 -0
- data/{lib/app → app}/controllers/status_controller.rb +0 -0
- data/{lib/app → app}/views/status/index.html.haml +0 -0
- metadata +6 -79
- data/.circleci/config.yml +0 -58
- data/.gitignore +0 -70
- data/.rubocop.yml +0 -33
- data/Gemfile +0 -5
- data/Gemfile.lock +0 -318
- data/Rakefile +0 -7
- data/bin/cron_server +0 -4
- data/test/controllers/status_controller_test.rb +0 -158
- data/test/factories/account_factories.rb +0 -9
- data/test/factories/notification_factories.rb +0 -14
- data/test/fixtures/mongoid.yml +0 -8
- data/test/fixtures/redis/host.yml +0 -5
- data/test/fixtures/redis/options.yml +0 -8
- data/test/fixtures/redis/sentinel.yml +0 -8
- data/test/fixtures/redis/url.yml +0 -2
- data/test/jobs/cron/server_test.rb +0 -160
- data/test/jobs/cron/switchboard_sync_configuration_test.rb +0 -64
- data/test/jobs/cron/trim_cron_servers_test.rb +0 -28
- data/test/jobs/cron/trim_failed_delayed_jobs_test.rb +0 -71
- data/test/models/concerns/app47_logger_test.rb +0 -88
- data/test/models/concerns/cdn_url_test.rb +0 -54
- data/test/models/concerns/email_able_test.rb +0 -145
- data/test/models/concerns/search_able_test.rb +0 -80
- data/test/models/concerns/standard_model_test.rb +0 -154
- data/test/models/concerns/system_configuration_test.rb +0 -212
- data/test/models/concerns/time_zone_able_test.rb +0 -77
- data/test/models/email_notification_test.rb +0 -297
- data/test/models/job_cron_tab_test.rb +0 -25
- data/test/models/notification_test.rb +0 -127
- data/test/models/redis_configuration_test.rb +0 -86
- data/test/models/slack_notification_test.rb +0 -91
- data/test/models/sms_notification_test.rb +0 -69
- data/test/models/smtp_configuration_test.rb +0 -66
- data/test/models/web47core_test.rb +0 -18
- data/test/notification_test_helper.rb +0 -146
- data/test/rails_setup.rb +0 -61
- data/test/shoulda_macros/mongoid.rb +0 -70
- data/test/test_helper.rb +0 -93
- data/test/test_models_helper.rb +0 -14
- data/web47core.gemspec +0 -58
data/Rakefile
DELETED
data/bin/cron_server
DELETED
@@ -1,158 +0,0 @@
|
|
1
|
-
# require 'test_helper'
|
2
|
-
# class StatusControllerTest < ActionDispatch::IntegrationTest
|
3
|
-
#
|
4
|
-
# context 'mongo status' do
|
5
|
-
# should 'pass mongo' do
|
6
|
-
# SystemConfiguration.configuration
|
7
|
-
# get status_index_path
|
8
|
-
# assert_response :success
|
9
|
-
# assert_select 'table', 1 do |table|
|
10
|
-
# assert_select table, 'tbody', 1 do |body|
|
11
|
-
# assert_select body, 'tr[1]', 1 do |row|
|
12
|
-
# assert_select row, 'td[2]', 1 do |col|
|
13
|
-
# assert_select col, 'i', 'check_circle', col
|
14
|
-
# end
|
15
|
-
# end
|
16
|
-
# end
|
17
|
-
# end
|
18
|
-
# end
|
19
|
-
# should 'render json' do
|
20
|
-
# SystemConfiguration.configuration
|
21
|
-
# get "/status.json"
|
22
|
-
# assert_response :success
|
23
|
-
# json = JSON.parse(response.body)
|
24
|
-
# mongo = json['mongo']
|
25
|
-
# assert mongo['success'], mongo.inspect
|
26
|
-
# assert_equal '1 Configs', mongo['message'], mongo.inspect
|
27
|
-
# end
|
28
|
-
# should 'render text success' do
|
29
|
-
# Cron::Server.find_or_create_server.become_primary
|
30
|
-
# SystemConfiguration.configuration
|
31
|
-
# get "/status.text"
|
32
|
-
# assert_response :success
|
33
|
-
# end
|
34
|
-
# should 'fail mongo' do
|
35
|
-
# SystemConfiguration.destroy_all
|
36
|
-
# get status_index_path
|
37
|
-
# assert_response :success
|
38
|
-
# assert_select 'table', 1 do |table|
|
39
|
-
# assert_select table, 'tbody', 1 do |body|
|
40
|
-
# assert_select body, 'tr[1]', 1 do |row|
|
41
|
-
# assert_select row, 'td[2]', 1 do |col|
|
42
|
-
# assert_select col, "i", 'error', col
|
43
|
-
# end
|
44
|
-
# end
|
45
|
-
# end
|
46
|
-
# end
|
47
|
-
# end
|
48
|
-
# should 'render json fail' do
|
49
|
-
# SystemConfiguration.destroy_all
|
50
|
-
# get "/status.json"
|
51
|
-
# assert_response :success
|
52
|
-
# json = JSON.parse(response.body)
|
53
|
-
# mongo = json['mongo']
|
54
|
-
# refute mongo['success'], mongo.inspect
|
55
|
-
# end
|
56
|
-
# should 'render text fail' do
|
57
|
-
# SystemConfiguration.destroy_all
|
58
|
-
# get "/status.text"
|
59
|
-
# assert_response :internal_server_error
|
60
|
-
# end
|
61
|
-
# end
|
62
|
-
#
|
63
|
-
# context 'redis status' do
|
64
|
-
# should 'pass redis' do
|
65
|
-
# get status_index_path
|
66
|
-
# assert_response :success
|
67
|
-
# # puts(response.body)
|
68
|
-
# assert_select 'table', 1 do |table|
|
69
|
-
# assert_select table, 'tbody', 1 do |body|
|
70
|
-
# assert_select body, 'tr[2]', 1 do |row|
|
71
|
-
# assert_select row, 'td[2]', 1 do |col|
|
72
|
-
# assert_select col, 'i', 'check_circle', col
|
73
|
-
# end
|
74
|
-
# end
|
75
|
-
# end
|
76
|
-
# end
|
77
|
-
# end
|
78
|
-
# should 'fail redis' do
|
79
|
-
# Rails.cache.expects(:write).once.raises('Redis not available')
|
80
|
-
# get status_index_path
|
81
|
-
# # Rails.cache.set 'redis-status-check', value
|
82
|
-
# assert_response :success
|
83
|
-
# assert_select 'table', 1 do |table|
|
84
|
-
# assert_select table, 'tbody', 1 do |body|
|
85
|
-
# assert_select body, 'tr[2]', 1 do |row|
|
86
|
-
# assert_select row, 'td[2]', 1 do |col|
|
87
|
-
# assert_select col, "i", 'error', col
|
88
|
-
# end
|
89
|
-
# end
|
90
|
-
# end
|
91
|
-
# end
|
92
|
-
# end
|
93
|
-
# end
|
94
|
-
#
|
95
|
-
# context 'job count' do
|
96
|
-
# should 'display job count' do
|
97
|
-
# get status_index_path
|
98
|
-
# assert_response :success
|
99
|
-
# assert_select 'td', "#{Delayed::Backend::Mongoid::Job.count} Jobs", response.body
|
100
|
-
# end
|
101
|
-
# end
|
102
|
-
#
|
103
|
-
# context 'cron job status' do
|
104
|
-
# should 'pass cron job' do
|
105
|
-
# server = Cron::Server.find_or_create_server
|
106
|
-
# server.become_primary
|
107
|
-
#
|
108
|
-
# get status_index_path
|
109
|
-
# assert_response :success
|
110
|
-
# assert_select 'table', 1 do |table|
|
111
|
-
# assert_select table, 'tbody', 1 do |body|
|
112
|
-
# assert_select body, 'tr[4]', 1 do |row|
|
113
|
-
# assert_select row, 'td[2]', 1 do |col|
|
114
|
-
# assert_select col, 'i', 'check_circle', col
|
115
|
-
# end
|
116
|
-
# assert_select row, 'td[3]', 1 do |col|
|
117
|
-
# assert_select col, 'h4', "Primary Server is alive: #{server.host_name}(#{server.pid}), last check in #{server.last_check_in_at}", col
|
118
|
-
# end
|
119
|
-
# end
|
120
|
-
# end
|
121
|
-
# end
|
122
|
-
# end
|
123
|
-
# should 'fail cron job with dead primary server' do
|
124
|
-
# server = Cron::Server.find_or_create_server
|
125
|
-
# server.become_primary
|
126
|
-
# server.set last_check_in_at: 1.days.ago.utc
|
127
|
-
#
|
128
|
-
# get status_index_path
|
129
|
-
# assert_response :success
|
130
|
-
# assert_select 'table', 1 do |table|
|
131
|
-
# assert_select table, 'tbody', 1 do |body|
|
132
|
-
# assert_select body, 'tr[4]', 1 do |row|
|
133
|
-
# assert_select row, 'td[2]', 1 do |col|
|
134
|
-
# assert_select col, 'i', 'error', col
|
135
|
-
# end
|
136
|
-
# assert_select row, 'td[3]', 1 do |col|
|
137
|
-
# assert_select col, 'h4', "Primary Server is DEAD: #{server.host_name}(#{server.pid}), last check in #{server.last_check_in_at}", col
|
138
|
-
# end
|
139
|
-
# end
|
140
|
-
# end
|
141
|
-
# end
|
142
|
-
# end
|
143
|
-
# should 'fail cron job' do
|
144
|
-
# Cron::Server.find_or_create_server
|
145
|
-
# get status_index_path
|
146
|
-
# assert_response :success
|
147
|
-
# assert_select 'table', 1 do |table|
|
148
|
-
# assert_select table, 'tbody', 1 do |body|
|
149
|
-
# assert_select body, 'tr[4]', 1 do |row|
|
150
|
-
# assert_select row, 'td[2]', 1 do |col|
|
151
|
-
# assert_select col, "i", 'error', col
|
152
|
-
# end
|
153
|
-
# end
|
154
|
-
# end
|
155
|
-
# end
|
156
|
-
# end
|
157
|
-
# end
|
158
|
-
# end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
FactoryBot.define do
|
2
|
-
|
3
|
-
factory :notification, class: Notification do
|
4
|
-
to { "noone@app47.com" }
|
5
|
-
message { "None message" }
|
6
|
-
end
|
7
|
-
|
8
|
-
factory :email_notification, class: EmailNotification do
|
9
|
-
to { "noone@app47.com" }
|
10
|
-
sender { "someone@app47.com" }
|
11
|
-
subject { "here me roar!" }
|
12
|
-
message { "None message" }
|
13
|
-
end
|
14
|
-
end
|
data/test/fixtures/mongoid.yml
DELETED
data/test/fixtures/redis/url.yml
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Cron
|
4
|
-
class ServerTest < ActiveSupport::TestCase
|
5
|
-
context 'Delayed job counting' do
|
6
|
-
setup do
|
7
|
-
@server = Cron::Server.find_or_create_server
|
8
|
-
Delayed::Worker.delay_jobs = true
|
9
|
-
end
|
10
|
-
teardown do
|
11
|
-
Delayed::Worker.delay_jobs = false
|
12
|
-
end
|
13
|
-
should 'return zero' do
|
14
|
-
assert_equal 0, @server.delayed_jobs_count
|
15
|
-
end
|
16
|
-
should 'return three' do
|
17
|
-
3.times do
|
18
|
-
MockDelayedJob.new.background
|
19
|
-
end
|
20
|
-
assert_equal 3, @server.delayed_jobs_count
|
21
|
-
end
|
22
|
-
should 'return zero with failed job' do
|
23
|
-
MockDelayedJob.new.background
|
24
|
-
job = Delayed::Backend::Mongoid::Job.first
|
25
|
-
job.set failed_at: Time.now.utc
|
26
|
-
assert_equal 0, @server.delayed_jobs_count
|
27
|
-
end
|
28
|
-
end
|
29
|
-
context 'AutoScalingJob' do
|
30
|
-
setup do
|
31
|
-
@auto_scaling_group_name = 'redmonocle-testing-group'
|
32
|
-
@config = SystemConfiguration.first
|
33
|
-
@config.set(aws_access_key_id: 'access_key_id',
|
34
|
-
aws_secret_access_key: 'secret_access_key',
|
35
|
-
aws_region: 'region',
|
36
|
-
aws_auto_scaling_group_name: @auto_scaling_group_name)
|
37
|
-
end
|
38
|
-
should 'not create any more instances if there are 1 - 249 jobs' do
|
39
|
-
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(49).at_least_once
|
40
|
-
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).never
|
41
|
-
Cron::Server.new.check_auto_scale
|
42
|
-
end
|
43
|
-
should 'create additional instances if there are 1,000 - 1,999 jobs and the number of instances currently running is less than the desired number of instances' do
|
44
|
-
Cron::Server.any_instance.expects(:current_desired_capacity).returns(0).at_least_once
|
45
|
-
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(51).at_least_once
|
46
|
-
params = { auto_scaling_group_name: @auto_scaling_group_name, min_size: 1, desired_capacity: 1 }
|
47
|
-
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).with(params).once
|
48
|
-
Cron::Server.new.check_auto_scale
|
49
|
-
end
|
50
|
-
should 'not create any additional instances if there are 1,000 - 1,999 jobs and the number of desired instances is less than or equal to the number of instances currently running' do
|
51
|
-
Cron::Server.any_instance.expects(:current_desired_capacity).returns(1).at_least_once
|
52
|
-
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(200).at_least_once
|
53
|
-
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).never
|
54
|
-
Cron::Server.new.check_auto_scale
|
55
|
-
end
|
56
|
-
should 'create additional instances if there are 2,000 - 2,999 jobs and the number of instances currently running is less than the desired number of instances' do
|
57
|
-
Cron::Server.any_instance.expects(:current_desired_capacity).returns(1).at_least_once
|
58
|
-
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(300).at_least_once
|
59
|
-
params = { auto_scaling_group_name: @auto_scaling_group_name, min_size: 2, desired_capacity: 2 }
|
60
|
-
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).with(params).once
|
61
|
-
Cron::Server.new.check_auto_scale
|
62
|
-
end
|
63
|
-
should 'not create any additional instances if there are 2,000 - 2,999 jobs and the number of desired instances is less than or equal to the number of instances currently running' do
|
64
|
-
Cron::Server.any_instance.expects(:current_desired_capacity).returns(3).at_least_once
|
65
|
-
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(750).at_least_once
|
66
|
-
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).never
|
67
|
-
Cron::Server.new.check_auto_scale
|
68
|
-
end
|
69
|
-
should 'create additional instances if there are 3,000 - 3,999 jobs and the number of instances currently running is less than the desired number of instances' do
|
70
|
-
Cron::Server.any_instance.expects(:current_desired_capacity).returns(1).at_least_once
|
71
|
-
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(300).at_least_once
|
72
|
-
params = { auto_scaling_group_name: @auto_scaling_group_name, min_size: 2, desired_capacity: 2 }
|
73
|
-
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).with(params).once
|
74
|
-
Cron::Server.new.check_auto_scale
|
75
|
-
end
|
76
|
-
should 'not create any additional instances if there are 3,000 - 3,999 jobs and the number of desired instances is less than or equal to the number of instances currently running' do
|
77
|
-
Cron::Server.any_instance.expects(:current_desired_capacity).returns(5).at_least_once
|
78
|
-
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(3_000).at_least_once
|
79
|
-
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).never
|
80
|
-
Cron::Server.new.check_auto_scale
|
81
|
-
end
|
82
|
-
should 'create additional instances if there are 4,000 jobs or more and the number of instances currently running is less than the desired number of instances' do
|
83
|
-
Cron::Server.any_instance.expects(:current_desired_capacity).returns(1).at_least_once
|
84
|
-
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(700).at_least_once
|
85
|
-
params = { auto_scaling_group_name: @auto_scaling_group_name, min_size: 3, desired_capacity: 3 }
|
86
|
-
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).with(params).once
|
87
|
-
Cron::Server.new.check_auto_scale
|
88
|
-
end
|
89
|
-
should 'not create any additional instances if there are 4,000 jobs or more and the number of desired instances is less than or equal to the number of instances currently running' do
|
90
|
-
Cron::Server.any_instance.expects(:current_desired_capacity).returns(7).at_least_once
|
91
|
-
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(4_000).at_least_once
|
92
|
-
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).never
|
93
|
-
Cron::Server.new.check_auto_scale
|
94
|
-
end
|
95
|
-
should 'remove all instances if there are no jobs left to run' do
|
96
|
-
Cron::Server.any_instance.expects(:current_desired_capacity).returns(7).at_least_once
|
97
|
-
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(0).at_least_once
|
98
|
-
params = { auto_scaling_group_name: @auto_scaling_group_name, min_size: 0, desired_capacity: 0 }
|
99
|
-
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).with(params).once
|
100
|
-
Cron::Server.new.check_auto_scale
|
101
|
-
end
|
102
|
-
should 'create additional instances by warming up a server' do
|
103
|
-
Cron::Server.any_instance.expects(:current_desired_capacity).returns(0).at_least_once
|
104
|
-
# Cron::Server.any_instance.expects(:delayed_jobs_count).returns(0).at_least_once
|
105
|
-
params = { auto_scaling_group_name: @auto_scaling_group_name, min_size: 1, desired_capacity: 1 }
|
106
|
-
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).with(params).once
|
107
|
-
Cron::Server.find_or_create_server.become_primary
|
108
|
-
Cron::Server.warm_up_server
|
109
|
-
end
|
110
|
-
end
|
111
|
-
context 'Run jobs' do
|
112
|
-
setup do
|
113
|
-
Cron::JobTab.ensure_cron_tabs
|
114
|
-
Cron::Tab.any_instance.expects(:time_to_run?).returns(true).at_least_once
|
115
|
-
Cron::TrimCronServers.expects(:perform_later).once
|
116
|
-
Cron::TrimNotifications.expects(:perform_later).once
|
117
|
-
end
|
118
|
-
should 'run jobs' do
|
119
|
-
assert_nothing_raised do
|
120
|
-
Cron::Server.find_or_create_server.execute
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
context 'Highlander' do
|
125
|
-
setup do
|
126
|
-
@s1 = Cron::Server.create! host_name: 's1', pid: '1123'
|
127
|
-
@s2 = Cron::Server.create! host_name: 's2', pid: '1124'
|
128
|
-
@s3 = Cron::Server.create! host_name: 's3', pid: '1125'
|
129
|
-
@s4 = Cron::Server.create! host_name: 's4', pid: '1126'
|
130
|
-
end
|
131
|
-
should 'allow one to become primary' do
|
132
|
-
assert_nothing_raised { @s1.become_primary }
|
133
|
-
assert_equal 1, Cron::Server.where(state: 'primary').count
|
134
|
-
end
|
135
|
-
should 'prevent second primary' do
|
136
|
-
assert_nothing_raised { @s1.become_primary }
|
137
|
-
refute @s2.update_attributes state: 'primary'
|
138
|
-
assert_equal 1, Cron::Server.where(state: 'primary').count
|
139
|
-
end
|
140
|
-
should 'determine to be alive ' do
|
141
|
-
server = Cron::Server.new host_name: 's1', pid: '1123', last_check_in_at: Time.now.utc
|
142
|
-
assert server.alive?
|
143
|
-
refute server.dead?
|
144
|
-
end
|
145
|
-
should 'determine to be dead' do
|
146
|
-
server = Cron::Server.new host_name: 's1', pid: '1123', last_check_in_at: 2.minutes.ago
|
147
|
-
refute server.alive?
|
148
|
-
assert server.dead?
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
class MockDelayedJob
|
155
|
-
def background
|
156
|
-
|
157
|
-
end
|
158
|
-
|
159
|
-
handle_asynchronously :background
|
160
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Cron
|
4
|
-
class SwitchboardSyncConfigurationTest < ActiveSupport::TestCase
|
5
|
-
setup do
|
6
|
-
@config = SystemConfiguration.configuration
|
7
|
-
end
|
8
|
-
|
9
|
-
context 'valid_environment?' do
|
10
|
-
should 'not run' do
|
11
|
-
refute Cron::SwitchboardSyncConfiguration.valid_environment?
|
12
|
-
end
|
13
|
-
|
14
|
-
should 'run' do
|
15
|
-
@config.switchboard_stack_api_token = 'abc123'
|
16
|
-
@config.switchboard_stack_id = 'abc123'
|
17
|
-
assert @config.save
|
18
|
-
assert Cron::SwitchboardSyncConfiguration.valid_environment?
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'update system configuration' do
|
23
|
-
setup do
|
24
|
-
@config.switchboard_base_url = 'https://switchboard.test.com'
|
25
|
-
@config.switchboard_stack_api_token = 'abc124w'
|
26
|
-
@config.switchboard_stack_id = 'sid'
|
27
|
-
assert @config.save
|
28
|
-
end
|
29
|
-
|
30
|
-
should 'update system configuration' do
|
31
|
-
stub = stub_request(:get, "#{SystemConfiguration.switchboard_base_url}/stacks/sid/items.json").to_return(status: 200, body: { results: { cdn_url: 'https://cdn.nowhere.com' } }.to_json)
|
32
|
-
Cron::SwitchboardSyncConfiguration.new.perform
|
33
|
-
assert_not_nil @config.reload
|
34
|
-
assert_equal 'https://cdn.nowhere.com', @config.cdn_url
|
35
|
-
assert_requested stub
|
36
|
-
end
|
37
|
-
|
38
|
-
should 'update crontab' do
|
39
|
-
App47Logger.expects(:log_debug).once
|
40
|
-
Cron::JobTab.ensure_cron_tabs
|
41
|
-
tab = Cron::JobTab.find_by name: 'switchboard_sync_models'
|
42
|
-
assert_equal '0 0 * * *', tab.to_string
|
43
|
-
stub = stub_request(:get, "#{SystemConfiguration.switchboard_base_url}/stacks/sid/items.json").to_return(status: 200, body: { results: { switchboard_sync_models_crontab: '1 2 3 4 5' } }.to_json)
|
44
|
-
Cron::SwitchboardSyncConfiguration.new.perform
|
45
|
-
assert_not_nil tab.reload
|
46
|
-
assert_equal '1 2 3 4 5', tab.to_string
|
47
|
-
assert_requested stub
|
48
|
-
end
|
49
|
-
should 'deal with unknown' do
|
50
|
-
App47Logger.expects(:log_debug).never
|
51
|
-
App47Logger.expects(:log_warn).once
|
52
|
-
Cron::JobTab.ensure_cron_tabs
|
53
|
-
tab = Cron::JobTab.find_by name: 'switchboard_sync_models'
|
54
|
-
assert_equal '0 0 * * *', tab.to_string
|
55
|
-
stub = stub_request(:get, "#{SystemConfiguration.switchboard_base_url}/stacks/sid/items.json").to_return(status: 200, body: { results: { sync_knowledge_base_job_crontab: '1 2 3 4 5' } }.to_json)
|
56
|
-
Cron::SwitchboardSyncConfiguration.new.perform
|
57
|
-
assert_nil Cron::JobTab.where(name: 'sync_knowledge_base_job_crontab').first
|
58
|
-
assert_not_nil tab.reload
|
59
|
-
assert_equal '0 0 * * *', tab.to_string
|
60
|
-
assert_requested stub
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|