misha-resque-web 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +89 -0
- data/Rakefile +34 -0
- data/app/assets/images/resque_web/idle.png +0 -0
- data/app/assets/images/resque_web/lifebuoy.png +0 -0
- data/app/assets/images/resque_web/poll.png +0 -0
- data/app/assets/images/resque_web/rails.png +0 -0
- data/app/assets/images/resque_web/working.png +0 -0
- data/app/assets/javascripts/resque_web/application.js +16 -0
- data/app/assets/javascripts/resque_web/bootstrap.js.coffee +4 -0
- data/app/assets/javascripts/resque_web/failure.js.coffee +7 -0
- data/app/assets/javascripts/resque_web/jquery.relative-date.js +47 -0
- data/app/assets/javascripts/resque_web/polling.js.coffee +25 -0
- data/app/assets/javascripts/resque_web/relative_date.js.coffee +27 -0
- data/app/assets/stylesheets/resque_web/application.css +13 -0
- data/app/assets/stylesheets/resque_web/bootstrap_and_overrides.css.scss.erb +146 -0
- data/app/controllers/resque_web/application_controller.rb +25 -0
- data/app/controllers/resque_web/failures_controller.rb +62 -0
- data/app/controllers/resque_web/overview_controller.rb +7 -0
- data/app/controllers/resque_web/queues_controller.rb +22 -0
- data/app/controllers/resque_web/stats_controller.rb +36 -0
- data/app/controllers/resque_web/workers_controller.rb +23 -0
- data/app/controllers/resque_web/working_controller.rb +8 -0
- data/app/helpers/resque_web/application_helper.rb +69 -0
- data/app/helpers/resque_web/failures_helper.rb +58 -0
- data/app/helpers/resque_web/overview_helper.rb +6 -0
- data/app/helpers/resque_web/queues_helper.rb +72 -0
- data/app/helpers/resque_web/stats_helper.rb +54 -0
- data/app/helpers/resque_web/workers_helper.rb +16 -0
- data/app/helpers/resque_web/working_helper.rb +19 -0
- data/app/views/layouts/resque_web/application.html.erb +76 -0
- data/app/views/resque_web/failures/_failed_job.html.erb +53 -0
- data/app/views/resque_web/failures/_overview.html.erb +24 -0
- data/app/views/resque_web/failures/index.html.erb +32 -0
- data/app/views/resque_web/failures/show.html.erb +20 -0
- data/app/views/resque_web/overview/show.html.erb +4 -0
- data/app/views/resque_web/queues/_queues.html.erb +4 -0
- data/app/views/resque_web/queues/_queues_advanced.html.erb +14 -0
- data/app/views/resque_web/queues/_queues_basic.html.erb +17 -0
- data/app/views/resque_web/queues/index.html.erb +1 -0
- data/app/views/resque_web/queues/show.html.erb +30 -0
- data/app/views/resque_web/stats/key.html.erb +26 -0
- data/app/views/resque_web/stats/keys.html.erb +17 -0
- data/app/views/resque_web/stats/redis.html.erb +14 -0
- data/app/views/resque_web/stats/resque.html.erb +14 -0
- data/app/views/resque_web/workers/index.html.erb +19 -0
- data/app/views/resque_web/workers/show.html.erb +38 -0
- data/app/views/resque_web/working/_working.html.erb +34 -0
- data/app/views/resque_web/working/index.html.erb +1 -0
- data/config/initializers/resque_config.rb +4 -0
- data/config/routes.rb +36 -0
- data/lib/resque_web/engine.rb +17 -0
- data/lib/resque_web/version.rb +3 -0
- data/lib/resque_web.rb +4 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/schema.rb +16 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/functional/failures_controller_test.rb +74 -0
- data/test/functional/overview_controller_test.rb +37 -0
- data/test/functional/queues_controller_test.rb +58 -0
- data/test/functional/stats_controller_test.rb +70 -0
- data/test/functional/workers_controller_test.rb +26 -0
- data/test/functional/working_controller_test.rb +19 -0
- data/test/integration/plugin_integration_test.rb +72 -0
- data/test/support/controller_test_helpers.rb +22 -0
- data/test/test_helper.rb +30 -0
- data/test/unit/helpers/failures_helper_test.rb +15 -0
- data/test/unit/helpers/jobs_helper_test.rb +4 -0
- data/test/unit/helpers/overview_helper_test.rb +4 -0
- data/test/unit/helpers/queues_helper_test.rb +4 -0
- data/test/unit/helpers/retry_controller_helper_test.rb +4 -0
- data/test/unit/helpers/stats_helper_test.rb +4 -0
- data/test/unit/helpers/workers_helper_test.rb +4 -0
- data/test/unit/helpers/working_helper_test.rb +4 -0
- metadata +263 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/422.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The change you wanted was rejected.</h1>
|
54
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/500.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>We're sorry, but something went wrong.</h1>
|
54
|
+
</div>
|
55
|
+
<p>If you are the application owner check the logs for more information.</p>
|
56
|
+
</body>
|
57
|
+
</html>
|
File without changes
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ResqueWeb
|
4
|
+
class FailuresControllerTest < ActionController::TestCase
|
5
|
+
include ControllerTestHelpers
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@routes = Engine.routes
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "GET /failures" do
|
12
|
+
it "renders the index page" do
|
13
|
+
visit(:index)
|
14
|
+
assert_template :index
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "DELETE /failures/:id" do
|
19
|
+
it "deletes the failure" do
|
20
|
+
Resque::Failure.expects(:remove).with('123')
|
21
|
+
visit(:destroy, {:id => 123}, :method => :delete)
|
22
|
+
assert_redirected_to failures_path
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "DELETE /failures/destroy_all" do
|
27
|
+
it "deletes all failures" do
|
28
|
+
Resque::Failure.expects(:clear).with('failed')
|
29
|
+
visit(:destroy_all, nil, :method => :delete)
|
30
|
+
assert_redirected_to failures_path
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "PUT /failures/:id/retry" do
|
35
|
+
it "retries the failure and remove the original message" do
|
36
|
+
Resque::Failure.expects(:requeue_and_remove).with('123')
|
37
|
+
visit(:retry, {:id => 123}, :method => :put)
|
38
|
+
assert_redirected_to failures_path
|
39
|
+
end
|
40
|
+
it "retries should work also in case of pre 2.0 Resque" do
|
41
|
+
Resque::Failure.expects(:requeue).with('123')
|
42
|
+
Resque::Failure.expects(:remove).with('123')
|
43
|
+
visit(:retry, {:id => 123}, :method => :put)
|
44
|
+
assert_redirected_to failures_path
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "PUT /failures/retry_all" do
|
49
|
+
it "retries all failures using requeue if no queue specified" do
|
50
|
+
Resque::Failure.stubs(:count).returns(2)
|
51
|
+
Resque::Failure.stubs(:requeue_and_remove).returns(true)
|
52
|
+
Resque::Failure.expects(:requeue_and_remove).with(0)
|
53
|
+
Resque::Failure.expects(:requeue_and_remove).with(1)
|
54
|
+
visit(:retry_all, nil, :method => :put)
|
55
|
+
assert_redirected_to failures_path
|
56
|
+
end
|
57
|
+
it "retries all failures should also work case of pre 2.0 Resque" do
|
58
|
+
Resque::Failure.stubs(:count).returns(2)
|
59
|
+
Resque::Failure.stubs(:requeue).returns(true)
|
60
|
+
Resque::Failure.expects(:requeue).with(0)
|
61
|
+
Resque::Failure.expects(:remove).with(0)
|
62
|
+
Resque::Failure.expects(:requeue).with(1)
|
63
|
+
Resque::Failure.expects(:remove).with(1)
|
64
|
+
visit(:retry_all, nil, :method => :put)
|
65
|
+
assert_redirected_to failures_path
|
66
|
+
end
|
67
|
+
it "retries all failures using requeue_queue if queue specified" do
|
68
|
+
Resque::Failure.expects(:requeue_queue).with('myqueue')
|
69
|
+
visit(:retry_all, {:queue=>"myqueue"}, :method => :put)
|
70
|
+
assert_redirected_to failures_path(:queue=>'myqueue')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ResqueWeb
|
4
|
+
|
5
|
+
class OverviewControllerTest < ActionController::TestCase
|
6
|
+
include ControllerTestHelpers
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@routes = Engine.routes
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "GET /" do
|
13
|
+
describe "when HTTP Basic Authentication is enabled" do
|
14
|
+
describe "and the currect username and password are supplied " do
|
15
|
+
it "should grant me access" do
|
16
|
+
visit(:show)
|
17
|
+
assert_response :ok
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "and the username and password are not supplied" do
|
22
|
+
it "should deny me access" do
|
23
|
+
visit(:show, {}, :auth => false)
|
24
|
+
assert_response :unauthorized
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "when HTTP Basic Authentication is disabled" do
|
30
|
+
it "should grant me access" do
|
31
|
+
visit(:show, {}, :auth => :disabled)
|
32
|
+
assert_response :ok
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ResqueWeb
|
4
|
+
class QueuesControllerTest < ActionController::TestCase
|
5
|
+
include ControllerTestHelpers
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@routes = Engine.routes
|
9
|
+
@pending_before_push = Resque.info[:pending]
|
10
|
+
Resque.push(queue_name, class: 'ExampleJob')
|
11
|
+
end
|
12
|
+
|
13
|
+
teardown do
|
14
|
+
Resque.remove_queue(queue_name)
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:queue_name) { 'example_queue' }
|
18
|
+
|
19
|
+
describe "GET /index" do
|
20
|
+
it "renders the index page" do
|
21
|
+
visit(:index)
|
22
|
+
assert_template :index
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "GET /show" do
|
27
|
+
it "renders the show page" do
|
28
|
+
visit(:show, id: queue_name)
|
29
|
+
assert_template :show
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "DELETE /destroy" do
|
34
|
+
it "deletes queues" do
|
35
|
+
visit(:destroy, {id: queue_name}, method: :delete)
|
36
|
+
assert_redirected_to queues_path
|
37
|
+
end
|
38
|
+
|
39
|
+
it "deletes queues" do
|
40
|
+
visit(:destroy, {id: queue_name}, method: :delete)
|
41
|
+
Resque.queues.include?(queue_name).wont_equal true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "PUT /clear" do
|
46
|
+
it "removes all pending jobs from a queue" do
|
47
|
+
visit(:clear, {id: queue_name}, method: :put)
|
48
|
+
pending_after_clear = Resque.info[:pending]
|
49
|
+
assert_equal @pending_before_push, pending_after_clear
|
50
|
+
end
|
51
|
+
|
52
|
+
it "redirects to the show page" do
|
53
|
+
visit(:clear, {id: queue_name}, method: :put)
|
54
|
+
assert_redirected_to queue_path(queue_name)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ResqueWeb
|
4
|
+
class StatsControllerTest < ActionController::TestCase
|
5
|
+
include ControllerTestHelpers
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@routes = Engine.routes
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "GET /index" do
|
12
|
+
it "redirects to resque" do
|
13
|
+
visit(:index)
|
14
|
+
assert_redirected_to action: "resque"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "GET /resque" do
|
19
|
+
it "renders the resque page" do
|
20
|
+
visit(:resque)
|
21
|
+
assert_template :resque
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "GET /resque.json" do
|
26
|
+
it "renders the resque page" do
|
27
|
+
visit(:resque, format: 'json')
|
28
|
+
assert_equal response.body, Hash[Resque.info.sort].to_json
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "GET /redis" do
|
33
|
+
it "renders the redis page" do
|
34
|
+
visit(:redis)
|
35
|
+
assert_template :redis
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "GET /redis.json" do
|
40
|
+
it "renders the redis page" do
|
41
|
+
expected = Resque.redis.info
|
42
|
+
Resque.redis.stubs(:info).returns(expected)
|
43
|
+
visit(:redis, format: 'json')
|
44
|
+
assert_equal response.body, Hash[expected.sort].to_json
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "GET /keys" do
|
49
|
+
it "renders the keys page" do
|
50
|
+
visit(:keys)
|
51
|
+
assert_template :keys
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "GET /keys/:id" do
|
56
|
+
it "renders the keys page" do
|
57
|
+
visit(:keys, id: "failed")
|
58
|
+
assert_template :key
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "GET /keys.json" do
|
63
|
+
it "renders the keys page" do
|
64
|
+
visit(:keys, format: 'json')
|
65
|
+
assert_equal response.body, Resque.keys.sort.to_json
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ResqueWeb
|
4
|
+
class WorkersControllerTest < ActionController::TestCase
|
5
|
+
include ControllerTestHelpers
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@routes = Engine.routes
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "GET /index" do
|
12
|
+
it "renders the index page" do
|
13
|
+
visit(:index)
|
14
|
+
assert_template :index
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "GET /show" do
|
19
|
+
it "renders the show page" do
|
20
|
+
visit(:show, id: "all")
|
21
|
+
assert_template :show
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ResqueWeb
|
4
|
+
class WorkingControllerTest < ActionController::TestCase
|
5
|
+
include ControllerTestHelpers
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@routes = Engine.routes
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "GET /index" do
|
12
|
+
it "renders the index page" do
|
13
|
+
visit(:index)
|
14
|
+
assert_template :index
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ResqueWeb
|
4
|
+
class PluginIntegrationTest < ActionDispatch::IntegrationTest
|
5
|
+
|
6
|
+
module ResqueWeb::Plugins::ResqueWebTestPlugin
|
7
|
+
class Engine < ::Rails::Engine
|
8
|
+
isolate_namespace ResqueWeb::Plugins::ResqueWebTestPlugin
|
9
|
+
end
|
10
|
+
class PlugintestController < ApplicationController
|
11
|
+
def index
|
12
|
+
render html: "hello from test plugin", layout: true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Engine.routes.draw do
|
17
|
+
resources :plugintest, :only => [:index]
|
18
|
+
root to: 'plugintest#index'
|
19
|
+
end
|
20
|
+
def self.engine_path
|
21
|
+
"/plugin_test"
|
22
|
+
end
|
23
|
+
def self.tabs
|
24
|
+
[{'plugin test' => Engine.app.url_helpers.plugintest_index_path}]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def visit(action, params = {}, options = {})
|
29
|
+
method = options.delete(:method) || :get
|
30
|
+
|
31
|
+
user = ENV["RESQUE_WEB_HTTP_BASIC_AUTH_USER"]
|
32
|
+
password = ENV["RESQUE_WEB_HTTP_BASIC_AUTH_PASSWORD"]
|
33
|
+
|
34
|
+
if options[:auth] == :disabled
|
35
|
+
ENV["RESQUE_WEB_HTTP_BASIC_AUTH_USER"] = nil
|
36
|
+
ENV["RESQUE_WEB_HTTP_BASIC_AUTH_PASSWORD"] = nil
|
37
|
+
else
|
38
|
+
env = {}
|
39
|
+
env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(
|
40
|
+
options[:user] || user, options[:password] || password
|
41
|
+
) unless options[:auth] == false
|
42
|
+
end
|
43
|
+
|
44
|
+
send(method, action, params: params, env: env)
|
45
|
+
|
46
|
+
ENV["RESQUE_WEB_HTTP_BASIC_AUTH_USER"] = user
|
47
|
+
ENV["RESQUE_WEB_HTTP_BASIC_AUTH_PASSWORD"] = password
|
48
|
+
end
|
49
|
+
|
50
|
+
setup do
|
51
|
+
@routes = Engine.routes
|
52
|
+
Dummy::Application.reload_routes!
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "resque web plugins" do
|
56
|
+
it "adds the routes" do
|
57
|
+
paths = @routes.routes.map{|m| m.path.spec.to_s}
|
58
|
+
paths.must_include "/plugin_test"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "renders the plugins action" do
|
62
|
+
visit "/resque_web/plugin_test/plugintest"
|
63
|
+
@response.body.must_include "hello from test plugin"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "adds a tab for the plugin" do
|
67
|
+
visit "/resque_web/"
|
68
|
+
@response.body.must_include "<a href=\"/resque_web/plugin_test/plugintest\">Plugin test</a>"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ControllerTestHelpers
|
2
|
+
def visit(action, params = {}, options = {})
|
3
|
+
method = options.delete(:method) || :get
|
4
|
+
|
5
|
+
user = ENV["RESQUE_WEB_HTTP_BASIC_AUTH_USER"]
|
6
|
+
password = ENV["RESQUE_WEB_HTTP_BASIC_AUTH_PASSWORD"]
|
7
|
+
|
8
|
+
if options[:auth] == :disabled
|
9
|
+
ENV["RESQUE_WEB_HTTP_BASIC_AUTH_USER"] = nil
|
10
|
+
ENV["RESQUE_WEB_HTTP_BASIC_AUTH_PASSWORD"] = nil
|
11
|
+
else
|
12
|
+
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(
|
13
|
+
options[:user] || user, options[:password] || password
|
14
|
+
) unless options[:auth] == false
|
15
|
+
end
|
16
|
+
|
17
|
+
send(method, action, params: params)
|
18
|
+
|
19
|
+
ENV["RESQUE_WEB_HTTP_BASIC_AUTH_USER"] = user
|
20
|
+
ENV["RESQUE_WEB_HTTP_BASIC_AUTH_PASSWORD"] = password
|
21
|
+
end
|
22
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'dotenv'
|
2
|
+
Dotenv.load!
|
3
|
+
|
4
|
+
require 'redcard'
|
5
|
+
require 'profiler' if RedCard.check :rubinius
|
6
|
+
|
7
|
+
require 'coveralls'
|
8
|
+
Coveralls.wear! 'rails'
|
9
|
+
|
10
|
+
ENV["RAILS_ENV"] = "test"
|
11
|
+
require File.expand_path('../dummy/config/environment', __FILE__)
|
12
|
+
require 'rails/test_help'
|
13
|
+
|
14
|
+
require 'minitest/spec'
|
15
|
+
require 'resque'
|
16
|
+
require 'mocha/setup'
|
17
|
+
|
18
|
+
Rails.backtrace_cleaner.remove_silencers!
|
19
|
+
|
20
|
+
# Load support files
|
21
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
22
|
+
|
23
|
+
# Load fixtures from the engine
|
24
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
25
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
26
|
+
end
|
27
|
+
|
28
|
+
ActionDispatch::IntegrationTest.app = Rack::Builder.new do
|
29
|
+
run Rails.application
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class FailuresHelperTest < ActionView::TestCase
|
4
|
+
include ResqueWeb::FailuresHelper
|
5
|
+
|
6
|
+
test "failure_queue_name without params queue" do
|
7
|
+
assert_equal failure_queue_name, "Failed"
|
8
|
+
end
|
9
|
+
|
10
|
+
test "failure_queue_name with a params queue" do
|
11
|
+
params[:queue] = "QueueName"
|
12
|
+
assert_equal failure_queue_name, "QueueName"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|