level_up 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. data/CHANGELOG.txt +7 -0
  2. data/README.md +29 -29
  3. data/app/controllers/level_up/jobs_controller.rb +15 -16
  4. data/app/helpers/level_up/home_helper.rb +5 -1
  5. data/app/models/level_up/job.rb +65 -55
  6. data/app/models/level_up/{state → task}/cancel.rb +1 -1
  7. data/app/models/level_up/{state → task}/end.rb +1 -1
  8. data/app/models/level_up/task/start.rb +8 -0
  9. data/app/models/level_up/{state.rb → task.rb} +13 -13
  10. data/app/views/level_up/home/index.html.erb +4 -4
  11. data/app/views/level_up/jobs/edit.html.erb +4 -4
  12. data/app/views/level_up/jobs/index.html.erb +7 -7
  13. data/app/views/level_up/jobs/show.html.erb +6 -6
  14. data/db/migrate/20130212111454_create_level_up_jobs.rb +4 -4
  15. data/lib/level_up/configuration.rb +14 -2
  16. data/lib/level_up/version.rb +1 -1
  17. data/test/dummy/app/models/account_banish.rb +18 -0
  18. data/test/dummy/app/models/account_downgrade.rb +13 -0
  19. data/test/dummy/app/{jobs → models}/account_upgrade.rb +3 -3
  20. data/test/dummy/db/development.sqlite3 +0 -0
  21. data/test/dummy/db/migrate/{20130212113009_create_delayed_jobs.rb → 20130404201224_create_delayed_jobs.rb} +0 -0
  22. data/test/dummy/db/migrate/{20130215111404_create_level_up_jobs.level_up.rb → 20130404201329_create_level_up_jobs.level_up.rb} +4 -4
  23. data/test/dummy/db/schema.rb +9 -9
  24. data/test/dummy/db/test.sqlite3 +0 -0
  25. data/test/dummy/log/development.log +4020 -0
  26. data/test/dummy/log/test.log +21327 -0
  27. data/test/dummy/tmp/cache/assets/C2C/CE0/sprockets%2F33f519d653c9b4886c417440a0993824 +0 -0
  28. data/test/dummy/tmp/cache/assets/C6A/F00/sprockets%2F177385361781d5fe78d217f1f48b8566 +0 -0
  29. data/test/dummy/tmp/cache/assets/C6C/ED0/sprockets%2F320c25374f5ea136824c04c256e1605b +0 -0
  30. data/test/dummy/tmp/cache/assets/C87/110/sprockets%2Fc4428c04b8830f451f7636c2811f975d +0 -0
  31. data/test/dummy/tmp/cache/assets/CB9/E40/sprockets%2F43e6286ecc7751fc65d32b72c6158940 +0 -0
  32. data/test/dummy/tmp/cache/assets/CCE/7E0/sprockets%2F7d295633b50bfa8b04345d5e600b343a +0 -0
  33. data/test/dummy/tmp/cache/assets/CD5/450/sprockets%2F2ac0e7e07211a99107e0ba7e2680c885 +0 -0
  34. data/test/dummy/tmp/cache/assets/CE4/220/sprockets%2Ff1a78dd6750c553265fd3a242d76c277 +0 -0
  35. data/test/dummy/tmp/cache/assets/CF7/BA0/sprockets%2F8f9487ea6943415e46a5d895e0920ebe +0 -0
  36. data/test/dummy/tmp/cache/assets/D0E/2B0/sprockets%2F3e386ff8d231b92766061c4fad4ad504 +0 -0
  37. data/test/dummy/tmp/cache/assets/D19/660/sprockets%2F018d64588c824dd3e7e6c8d6d0d6510e +0 -0
  38. data/test/dummy/tmp/cache/assets/D25/E10/sprockets%2F989ec024c5db6ae875689b410f8e6d53 +0 -0
  39. data/test/dummy/tmp/cache/assets/D33/200/sprockets%2Fc291105cf21ca8e744c65f3d4f446aa1 +0 -0
  40. data/test/dummy/tmp/cache/assets/D34/610/sprockets%2Fcc081ecb5b32894151f16a144383befe +0 -0
  41. data/test/dummy/tmp/cache/assets/D4D/110/sprockets%2Fc16dfb491d9b98f482b4f0059dd355b8 +0 -0
  42. data/test/dummy/tmp/cache/assets/D4F/890/sprockets%2Fe3f96e9aa9b032c43788676c5ce066db +0 -0
  43. data/test/dummy/tmp/cache/assets/D53/370/sprockets%2F1cf0ca91840a1483edcac4d0c403b149 +0 -0
  44. data/test/dummy/tmp/cache/assets/D69/B90/sprockets%2Fdb0ee3e51128419c85616ceaca66ab58 +0 -0
  45. data/test/dummy/tmp/cache/assets/D75/B20/sprockets%2Fb659146edbe91be3b1b9d64cb9370c76 +0 -0
  46. data/test/dummy/tmp/cache/assets/D79/430/sprockets%2Fc030f9d26fab468c49dc494195d77eab +0 -0
  47. data/test/dummy/tmp/cache/assets/D9D/3C0/sprockets%2F3019d99c7bae1e55eb7c2bf4688b1b1a +0 -0
  48. data/test/dummy/tmp/cache/assets/DAA/1A0/sprockets%2Fba643993838fce8ddc1d42e6ce1fc346 +0 -0
  49. data/test/dummy/tmp/cache/assets/DD4/DA0/sprockets%2F17fadf3354a429c53acfe9fca6268d5d +0 -0
  50. data/test/dummy/tmp/cache/assets/DF8/880/sprockets%2F255d8bde2bf6681724e4ddedcc3cbc02 +0 -0
  51. data/test/dummy/tmp/job_1.svg +78 -0
  52. data/test/dummy/tmp/job_2.svg +78 -0
  53. data/test/dummy/tmp/job_3.svg +78 -0
  54. data/test/unit/level_up/job_test.rb +124 -52
  55. metadata +84 -19
  56. data/app/models/level_up/state/start.rb +0 -9
  57. data/app/views/level_up/home/workflow.html.erb +0 -5
  58. data/test/dummy/app/jobs/account_banish.rb +0 -18
  59. data/test/dummy/app/jobs/account_downgrade.rb +0 -13
  60. data/test/dummy/app/jobs/mailing_list_subscription.rb +0 -15
@@ -0,0 +1,78 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
3
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <!-- Generated by graphviz version 2.30.1 (20130311.1815)
5
+ -->
6
+ <!-- Title: G Pages: 1 -->
7
+ <svg width="242pt" height="332pt"
8
+ viewBox="0.00 0.00 242.00 332.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
9
+ <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 328)">
10
+ <title>G</title>
11
+ <polygon fill="#fafbfb" stroke="#fafbfb" points="-4,5 -4,-328 239,-328 239,5 -4,5"/>
12
+ <!-- start -->
13
+ <g id="node1" class="node"><title>start</title>
14
+ <polygon fill="#5db1a4" stroke="#048282" points="84,-324 30,-324 30,-288 84,-288 84,-324"/>
15
+ <text text-anchor="middle" x="57" y="-302.209" font-family="Verdana" font-size="14.00" fill="white">start</text>
16
+ </g>
17
+ <!-- banish -->
18
+ <g id="node2" class="node"><title>banish</title>
19
+ <polygon fill="#666666" stroke="#111111" points="87.4891,-252 26.5109,-252 26.5109,-216 87.4891,-216 87.4891,-252"/>
20
+ <text text-anchor="middle" x="57" y="-230.209" font-family="Verdana" font-size="14.00" fill="white">banish</text>
21
+ </g>
22
+ <!-- start&#45;&gt;banish -->
23
+ <g id="edge1" class="edge"><title>start&#45;&gt;banish</title>
24
+ <path fill="none" stroke="#000000" d="M57,-287.697C57,-279.983 57,-270.712 57,-262.112"/>
25
+ <polygon fill="#000000" stroke="#000000" points="57,-252.104 61.5001,-262.104 57,-257.104 57.0001,-262.104 57.0001,-262.104 57.0001,-262.104 57,-257.104 52.5001,-262.104 57,-252.104 57,-252.104"/>
26
+ </g>
27
+ <!-- check account -->
28
+ <g id="node3" class="node"><title>check account</title>
29
+ <polygon fill="#666666" stroke="#111111" points="114.293,-180 -0.293353,-180 -0.293353,-144 114.293,-144 114.293,-180"/>
30
+ <text text-anchor="middle" x="57" y="-158.209" font-family="Verdana" font-size="14.00" fill="white">check account</text>
31
+ </g>
32
+ <!-- banish&#45;&gt;check account -->
33
+ <g id="edge2" class="edge"><title>banish&#45;&gt;check account</title>
34
+ <path fill="none" stroke="#000000" d="M51.0843,-215.697C50.2886,-207.983 50.0621,-198.712 50.4047,-190.112"/>
35
+ <polygon fill="#000000" stroke="#000000" points="51.105,-180.104 54.8959,-190.394 50.7559,-185.092 50.4069,-190.08 50.4069,-190.08 50.4069,-190.08 50.7559,-185.092 45.9179,-189.766 51.105,-180.104 51.105,-180.104"/>
36
+ </g>
37
+ <!-- email notification -->
38
+ <g id="node5" class="node"><title>email notification</title>
39
+ <polygon fill="#666666" stroke="#111111" points="234.15,-108 97.8501,-108 97.8501,-72 234.15,-72 234.15,-108"/>
40
+ <text text-anchor="middle" x="166" y="-86.2088" font-family="Verdana" font-size="14.00" fill="white">email notification</text>
41
+ </g>
42
+ <!-- banish&#45;&gt;email notification -->
43
+ <g id="edge3" class="edge"><title>banish&#45;&gt;email notification</title>
44
+ <path fill="none" stroke="#000000" d="M83.4673,-215.936C96.5779,-206.515 111.928,-193.914 123,-180 138.035,-161.106 149.533,-136.094 156.84,-117.397"/>
45
+ <polygon fill="#000000" stroke="#000000" points="160.37,-108.001 161.066,-118.945 158.611,-112.682 156.853,-117.362 156.853,-117.362 156.853,-117.362 158.611,-112.682 152.64,-115.78 160.37,-108.001 160.37,-108.001"/>
46
+ </g>
47
+ <!-- check account&#45;&gt;banish -->
48
+ <g id="edge4" class="edge"><title>check account&#45;&gt;banish</title>
49
+ <path fill="none" stroke="#000000" d="M62.895,-180.104C63.7005,-187.791 63.9369,-197.054 63.604,-205.665"/>
50
+ <polygon fill="#000000" stroke="#000000" points="62.9157,-215.697 59.1109,-205.412 63.258,-210.708 63.6003,-205.72 63.6003,-205.72 63.6003,-205.72 63.258,-210.708 68.0898,-206.028 62.9157,-215.697 62.9157,-215.697"/>
51
+ </g>
52
+ <!-- report -->
53
+ <g id="node4" class="node"><title>report</title>
54
+ <polygon fill="#666666" stroke="#111111" points="79.2689,-108 20.7311,-108 20.7311,-72 79.2689,-72 79.2689,-108"/>
55
+ <text text-anchor="middle" x="50" y="-86.2088" font-family="Verdana" font-size="14.00" fill="white">report</text>
56
+ </g>
57
+ <!-- check account&#45;&gt;report -->
58
+ <g id="edge5" class="edge"><title>check account&#45;&gt;report</title>
59
+ <path fill="none" stroke="#000000" d="M55.2697,-143.697C54.4983,-135.983 53.5712,-126.712 52.7112,-118.112"/>
60
+ <polygon fill="#000000" stroke="#000000" points="51.7104,-108.104 57.1832,-117.607 52.208,-113.08 52.7056,-118.055 52.7056,-118.055 52.7056,-118.055 52.208,-113.08 48.2279,-118.503 51.7104,-108.104 51.7104,-108.104"/>
61
+ </g>
62
+ <!-- end -->
63
+ <g id="node6" class="node"><title>end</title>
64
+ <polygon fill="#b40d28" stroke="#600615" points="135,-36 81,-36 81,-0 135,-0 135,-36"/>
65
+ <text text-anchor="middle" x="108" y="-14.2088" font-family="Verdana" font-size="14.00" fill="white">end</text>
66
+ </g>
67
+ <!-- report&#45;&gt;end -->
68
+ <g id="edge6" class="edge"><title>report&#45;&gt;end</title>
69
+ <path fill="none" stroke="#000000" d="M64.3371,-71.6966C71.2905,-63.3046 79.7702,-53.0705 87.4006,-43.8613"/>
70
+ <polygon fill="#000000" stroke="#000000" points="93.8278,-36.1043 90.9127,-46.6757 90.6377,-39.9545 87.4476,-43.8046 87.4476,-43.8046 87.4476,-43.8046 90.6377,-39.9545 83.9825,-40.9335 93.8278,-36.1043 93.8278,-36.1043"/>
71
+ </g>
72
+ <!-- email notification&#45;&gt;end -->
73
+ <g id="edge7" class="edge"><title>email notification&#45;&gt;end</title>
74
+ <path fill="none" stroke="#000000" d="M151.663,-71.6966C144.709,-63.3046 136.23,-53.0705 128.599,-43.8613"/>
75
+ <polygon fill="#000000" stroke="#000000" points="122.172,-36.1043 132.017,-40.9335 125.362,-39.9545 128.552,-43.8046 128.552,-43.8046 128.552,-43.8046 125.362,-39.9545 125.087,-46.6757 122.172,-36.1043 122.172,-36.1043"/>
76
+ </g>
77
+ </g>
78
+ </svg>
@@ -0,0 +1,78 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
3
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <!-- Generated by graphviz version 2.30.1 (20130311.1815)
5
+ -->
6
+ <!-- Title: G Pages: 1 -->
7
+ <svg width="242pt" height="332pt"
8
+ viewBox="0.00 0.00 242.00 332.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
9
+ <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 328)">
10
+ <title>G</title>
11
+ <polygon fill="#fafbfb" stroke="#fafbfb" points="-4,5 -4,-328 239,-328 239,5 -4,5"/>
12
+ <!-- start -->
13
+ <g id="node1" class="node"><title>start</title>
14
+ <polygon fill="#5db1a4" stroke="#048282" points="84,-324 30,-324 30,-288 84,-288 84,-324"/>
15
+ <text text-anchor="middle" x="57" y="-302.209" font-family="Verdana" font-size="14.00" fill="white">start</text>
16
+ </g>
17
+ <!-- banish -->
18
+ <g id="node2" class="node"><title>banish</title>
19
+ <polygon fill="#666666" stroke="#111111" points="87.4891,-252 26.5109,-252 26.5109,-216 87.4891,-216 87.4891,-252"/>
20
+ <text text-anchor="middle" x="57" y="-230.209" font-family="Verdana" font-size="14.00" fill="white">banish</text>
21
+ </g>
22
+ <!-- start&#45;&gt;banish -->
23
+ <g id="edge1" class="edge"><title>start&#45;&gt;banish</title>
24
+ <path fill="none" stroke="#000000" d="M57,-287.697C57,-279.983 57,-270.712 57,-262.112"/>
25
+ <polygon fill="#000000" stroke="#000000" points="57,-252.104 61.5001,-262.104 57,-257.104 57.0001,-262.104 57.0001,-262.104 57.0001,-262.104 57,-257.104 52.5001,-262.104 57,-252.104 57,-252.104"/>
26
+ </g>
27
+ <!-- check account -->
28
+ <g id="node3" class="node"><title>check account</title>
29
+ <polygon fill="#666666" stroke="#111111" points="114.293,-180 -0.293353,-180 -0.293353,-144 114.293,-144 114.293,-180"/>
30
+ <text text-anchor="middle" x="57" y="-158.209" font-family="Verdana" font-size="14.00" fill="white">check account</text>
31
+ </g>
32
+ <!-- banish&#45;&gt;check account -->
33
+ <g id="edge2" class="edge"><title>banish&#45;&gt;check account</title>
34
+ <path fill="none" stroke="#000000" d="M51.0843,-215.697C50.2886,-207.983 50.0621,-198.712 50.4047,-190.112"/>
35
+ <polygon fill="#000000" stroke="#000000" points="51.105,-180.104 54.8959,-190.394 50.7559,-185.092 50.4069,-190.08 50.4069,-190.08 50.4069,-190.08 50.7559,-185.092 45.9179,-189.766 51.105,-180.104 51.105,-180.104"/>
36
+ </g>
37
+ <!-- email notification -->
38
+ <g id="node5" class="node"><title>email notification</title>
39
+ <polygon fill="#666666" stroke="#111111" points="234.15,-108 97.8501,-108 97.8501,-72 234.15,-72 234.15,-108"/>
40
+ <text text-anchor="middle" x="166" y="-86.2088" font-family="Verdana" font-size="14.00" fill="white">email notification</text>
41
+ </g>
42
+ <!-- banish&#45;&gt;email notification -->
43
+ <g id="edge3" class="edge"><title>banish&#45;&gt;email notification</title>
44
+ <path fill="none" stroke="#000000" d="M83.4673,-215.936C96.5779,-206.515 111.928,-193.914 123,-180 138.035,-161.106 149.533,-136.094 156.84,-117.397"/>
45
+ <polygon fill="#000000" stroke="#000000" points="160.37,-108.001 161.066,-118.945 158.611,-112.682 156.853,-117.362 156.853,-117.362 156.853,-117.362 158.611,-112.682 152.64,-115.78 160.37,-108.001 160.37,-108.001"/>
46
+ </g>
47
+ <!-- check account&#45;&gt;banish -->
48
+ <g id="edge4" class="edge"><title>check account&#45;&gt;banish</title>
49
+ <path fill="none" stroke="#000000" d="M62.895,-180.104C63.7005,-187.791 63.9369,-197.054 63.604,-205.665"/>
50
+ <polygon fill="#000000" stroke="#000000" points="62.9157,-215.697 59.1109,-205.412 63.258,-210.708 63.6003,-205.72 63.6003,-205.72 63.6003,-205.72 63.258,-210.708 68.0898,-206.028 62.9157,-215.697 62.9157,-215.697"/>
51
+ </g>
52
+ <!-- report -->
53
+ <g id="node4" class="node"><title>report</title>
54
+ <polygon fill="#666666" stroke="#111111" points="79.2689,-108 20.7311,-108 20.7311,-72 79.2689,-72 79.2689,-108"/>
55
+ <text text-anchor="middle" x="50" y="-86.2088" font-family="Verdana" font-size="14.00" fill="white">report</text>
56
+ </g>
57
+ <!-- check account&#45;&gt;report -->
58
+ <g id="edge5" class="edge"><title>check account&#45;&gt;report</title>
59
+ <path fill="none" stroke="#000000" d="M55.2697,-143.697C54.4983,-135.983 53.5712,-126.712 52.7112,-118.112"/>
60
+ <polygon fill="#000000" stroke="#000000" points="51.7104,-108.104 57.1832,-117.607 52.208,-113.08 52.7056,-118.055 52.7056,-118.055 52.7056,-118.055 52.208,-113.08 48.2279,-118.503 51.7104,-108.104 51.7104,-108.104"/>
61
+ </g>
62
+ <!-- end -->
63
+ <g id="node6" class="node"><title>end</title>
64
+ <polygon fill="#b40d28" stroke="#600615" points="135,-36 81,-36 81,-0 135,-0 135,-36"/>
65
+ <text text-anchor="middle" x="108" y="-14.2088" font-family="Verdana" font-size="14.00" fill="white">end</text>
66
+ </g>
67
+ <!-- report&#45;&gt;end -->
68
+ <g id="edge6" class="edge"><title>report&#45;&gt;end</title>
69
+ <path fill="none" stroke="#000000" d="M64.3371,-71.6966C71.2905,-63.3046 79.7702,-53.0705 87.4006,-43.8613"/>
70
+ <polygon fill="#000000" stroke="#000000" points="93.8278,-36.1043 90.9127,-46.6757 90.6377,-39.9545 87.4476,-43.8046 87.4476,-43.8046 87.4476,-43.8046 90.6377,-39.9545 83.9825,-40.9335 93.8278,-36.1043 93.8278,-36.1043"/>
71
+ </g>
72
+ <!-- email notification&#45;&gt;end -->
73
+ <g id="edge7" class="edge"><title>email notification&#45;&gt;end</title>
74
+ <path fill="none" stroke="#000000" d="M151.663,-71.6966C144.709,-63.3046 136.23,-53.0705 128.599,-43.8613"/>
75
+ <polygon fill="#000000" stroke="#000000" points="122.172,-36.1043 132.017,-40.9335 125.362,-39.9545 128.552,-43.8046 128.552,-43.8046 128.552,-43.8046 125.362,-39.9545 125.087,-46.6757 122.172,-36.1043 122.172,-36.1043"/>
76
+ </g>
77
+ </g>
78
+ </svg>
@@ -0,0 +1,78 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
3
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <!-- Generated by graphviz version 2.30.1 (20130311.1815)
5
+ -->
6
+ <!-- Title: G Pages: 1 -->
7
+ <svg width="242pt" height="332pt"
8
+ viewBox="0.00 0.00 242.00 332.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
9
+ <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 328)">
10
+ <title>G</title>
11
+ <polygon fill="#fafbfb" stroke="#fafbfb" points="-4,5 -4,-328 239,-328 239,5 -4,5"/>
12
+ <!-- start -->
13
+ <g id="node1" class="node"><title>start</title>
14
+ <polygon fill="#5db1a4" stroke="#048282" points="84,-324 30,-324 30,-288 84,-288 84,-324"/>
15
+ <text text-anchor="middle" x="57" y="-302.209" font-family="Verdana" font-size="14.00" fill="white">start</text>
16
+ </g>
17
+ <!-- banish -->
18
+ <g id="node2" class="node"><title>banish</title>
19
+ <polygon fill="#666666" stroke="#111111" points="87.4891,-252 26.5109,-252 26.5109,-216 87.4891,-216 87.4891,-252"/>
20
+ <text text-anchor="middle" x="57" y="-230.209" font-family="Verdana" font-size="14.00" fill="white">banish</text>
21
+ </g>
22
+ <!-- start&#45;&gt;banish -->
23
+ <g id="edge1" class="edge"><title>start&#45;&gt;banish</title>
24
+ <path fill="none" stroke="#000000" d="M57,-287.697C57,-279.983 57,-270.712 57,-262.112"/>
25
+ <polygon fill="#000000" stroke="#000000" points="57,-252.104 61.5001,-262.104 57,-257.104 57.0001,-262.104 57.0001,-262.104 57.0001,-262.104 57,-257.104 52.5001,-262.104 57,-252.104 57,-252.104"/>
26
+ </g>
27
+ <!-- check account -->
28
+ <g id="node3" class="node"><title>check account</title>
29
+ <polygon fill="#666666" stroke="#111111" points="114.293,-180 -0.293353,-180 -0.293353,-144 114.293,-144 114.293,-180"/>
30
+ <text text-anchor="middle" x="57" y="-158.209" font-family="Verdana" font-size="14.00" fill="white">check account</text>
31
+ </g>
32
+ <!-- banish&#45;&gt;check account -->
33
+ <g id="edge2" class="edge"><title>banish&#45;&gt;check account</title>
34
+ <path fill="none" stroke="#000000" d="M51.0843,-215.697C50.2886,-207.983 50.0621,-198.712 50.4047,-190.112"/>
35
+ <polygon fill="#000000" stroke="#000000" points="51.105,-180.104 54.8959,-190.394 50.7559,-185.092 50.4069,-190.08 50.4069,-190.08 50.4069,-190.08 50.7559,-185.092 45.9179,-189.766 51.105,-180.104 51.105,-180.104"/>
36
+ </g>
37
+ <!-- email notification -->
38
+ <g id="node5" class="node"><title>email notification</title>
39
+ <polygon fill="#666666" stroke="#111111" points="234.15,-108 97.8501,-108 97.8501,-72 234.15,-72 234.15,-108"/>
40
+ <text text-anchor="middle" x="166" y="-86.2088" font-family="Verdana" font-size="14.00" fill="white">email notification</text>
41
+ </g>
42
+ <!-- banish&#45;&gt;email notification -->
43
+ <g id="edge3" class="edge"><title>banish&#45;&gt;email notification</title>
44
+ <path fill="none" stroke="#000000" d="M83.4673,-215.936C96.5779,-206.515 111.928,-193.914 123,-180 138.035,-161.106 149.533,-136.094 156.84,-117.397"/>
45
+ <polygon fill="#000000" stroke="#000000" points="160.37,-108.001 161.066,-118.945 158.611,-112.682 156.853,-117.362 156.853,-117.362 156.853,-117.362 158.611,-112.682 152.64,-115.78 160.37,-108.001 160.37,-108.001"/>
46
+ </g>
47
+ <!-- check account&#45;&gt;banish -->
48
+ <g id="edge4" class="edge"><title>check account&#45;&gt;banish</title>
49
+ <path fill="none" stroke="#000000" d="M62.895,-180.104C63.7005,-187.791 63.9369,-197.054 63.604,-205.665"/>
50
+ <polygon fill="#000000" stroke="#000000" points="62.9157,-215.697 59.1109,-205.412 63.258,-210.708 63.6003,-205.72 63.6003,-205.72 63.6003,-205.72 63.258,-210.708 68.0898,-206.028 62.9157,-215.697 62.9157,-215.697"/>
51
+ </g>
52
+ <!-- report -->
53
+ <g id="node4" class="node"><title>report</title>
54
+ <polygon fill="#666666" stroke="#111111" points="79.2689,-108 20.7311,-108 20.7311,-72 79.2689,-72 79.2689,-108"/>
55
+ <text text-anchor="middle" x="50" y="-86.2088" font-family="Verdana" font-size="14.00" fill="white">report</text>
56
+ </g>
57
+ <!-- check account&#45;&gt;report -->
58
+ <g id="edge5" class="edge"><title>check account&#45;&gt;report</title>
59
+ <path fill="none" stroke="#000000" d="M55.2697,-143.697C54.4983,-135.983 53.5712,-126.712 52.7112,-118.112"/>
60
+ <polygon fill="#000000" stroke="#000000" points="51.7104,-108.104 57.1832,-117.607 52.208,-113.08 52.7056,-118.055 52.7056,-118.055 52.7056,-118.055 52.208,-113.08 48.2279,-118.503 51.7104,-108.104 51.7104,-108.104"/>
61
+ </g>
62
+ <!-- end -->
63
+ <g id="node6" class="node"><title>end</title>
64
+ <polygon fill="#b40d28" stroke="#600615" points="135,-36 81,-36 81,-0 135,-0 135,-36"/>
65
+ <text text-anchor="middle" x="108" y="-14.2088" font-family="Verdana" font-size="14.00" fill="white">end</text>
66
+ </g>
67
+ <!-- report&#45;&gt;end -->
68
+ <g id="edge6" class="edge"><title>report&#45;&gt;end</title>
69
+ <path fill="none" stroke="#000000" d="M64.3371,-71.6966C71.2905,-63.3046 79.7702,-53.0705 87.4006,-43.8613"/>
70
+ <polygon fill="#000000" stroke="#000000" points="93.8278,-36.1043 90.9127,-46.6757 90.6377,-39.9545 87.4476,-43.8046 87.4476,-43.8046 87.4476,-43.8046 90.6377,-39.9545 83.9825,-40.9335 93.8278,-36.1043 93.8278,-36.1043"/>
71
+ </g>
72
+ <!-- email notification&#45;&gt;end -->
73
+ <g id="edge7" class="edge"><title>email notification&#45;&gt;end</title>
74
+ <path fill="none" stroke="#000000" d="M151.663,-71.6966C144.709,-63.3046 136.23,-53.0705 128.599,-43.8613"/>
75
+ <polygon fill="#000000" stroke="#000000" points="122.172,-36.1043 132.017,-40.9335 125.362,-39.9545 128.552,-43.8046 128.552,-43.8046 128.552,-43.8046 125.362,-39.9545 125.087,-46.6757 122.172,-36.1043 122.172,-36.1043"/>
76
+ </g>
77
+ </g>
78
+ </svg>
@@ -5,50 +5,71 @@ require 'delayed_job_active_record'
5
5
  module LevelUp
6
6
  class TestJob < Job
7
7
  job do
8
- state :start, moves_to: :first_node
9
- state :first_node, moves_to: [:second_node, :error_node, :timer_node, :task_node]
10
- state :second_node, moves_to: [:end]
11
- state :error_node
12
- state :timer_node
13
- state :task_node
8
+ task :start, transitions: :first_node
9
+ task :first_node, transitions: [:second_node, :error_node, :timer_node, :task_node]
10
+ task :second_node, transitions: [:end]
11
+ task :error_node
12
+ task :timer_node
13
+ task :task_node
14
14
  end
15
15
 
16
16
  def second_node
17
- move_to :end
17
+ move_to! :end
18
18
  end
19
19
  end
20
20
 
21
- class AbstractFirstNode < State
21
+ class CustomTaskJob < LevelUp::Job
22
+ job do
23
+ task :start, class_name: "CustomNode", transitions: :first_node
24
+ task :first_node, class_name: "CustomNode", transitions: :end
25
+ task :cancel, class_name: "CustomNode"
26
+ task :end, class_name: "CustomNode"
27
+ end
28
+
29
+ def first_node
30
+ end
31
+ end
32
+
33
+ class CustomTaskError < StandardError
34
+ end
35
+
36
+ class CustomTask < Task
22
37
  def run
23
- move_to :second_node
38
+ raise CustomTaskError.new("raised from task #{job.task}")
39
+ end
40
+ end
41
+
42
+ class AbstractFirstNode < Task
43
+ def run
44
+ move_to! :second_node
24
45
  end
25
46
  end
26
47
 
27
48
  class TestJob::FirstNode < AbstractFirstNode
28
49
  end
29
50
 
30
- class TestJob::ErrorNode < State
51
+ class TestJob::ErrorNode < Task
31
52
  def run
32
53
  raise "bad news"
33
54
  end
34
55
  end
35
56
 
36
- class TestJob::TimerNode < State
57
+ class TestJob::TimerNode < Task
37
58
  def run
38
- retry_in 1.hour
59
+ retry_in! 1.hour
39
60
  end
40
61
  end
41
62
 
42
- class TestJob::TaskNode < State
63
+ class TestJob::TaskNode < Task
43
64
  def run
44
- manual_task "a lot of work"
65
+ manual_task! "a lot of work"
45
66
  end
46
67
  end
47
68
 
48
69
  class LevelUpTest < ActiveSupport::TestCase
49
70
  def setup
50
- @job = TestJob.new
51
- @job.save
71
+ @job = TestJob.create
72
+ @custom_task_job = CustomTaskJob.create
52
73
  end
53
74
 
54
75
  test "should return the schema" do
@@ -63,42 +84,42 @@ module LevelUp
63
84
  }, @job.schema)
64
85
  end
65
86
 
66
- test "should return the list of states" do
67
- assert_equal([:start, :first_node, :second_node, :error_node, :timer_node, :task_node, :end], @job.states)
87
+ test "should return the list of tasks" do
88
+ assert_equal([:start, :first_node, :second_node, :error_node, :timer_node, :task_node, :end], @job.tasks)
68
89
  end
69
90
 
70
- test "should return list of transitions for a given state" do
91
+ test "should return list of transitions for a given task" do
71
92
  assert_equal([:first_node], @job.transitions(:start))
72
- assert_equal([:first_node], @job.state_transitions)
93
+ assert_equal([:first_node], @job.task_transitions)
73
94
 
74
- @job.state = "first_node"
95
+ @job.task = "first_node"
75
96
  assert_equal([:second_node, :error_node, :timer_node, :task_node], @job.transitions(:first_node))
76
- assert_equal([:second_node, :error_node, :timer_node, :task_node], @job.state_transitions)
97
+ assert_equal([:second_node, :error_node, :timer_node, :task_node], @job.task_transitions)
77
98
 
78
- @job.state = "second_node"
99
+ @job.task = "second_node"
79
100
  assert_equal([:end], @job.transitions(:second_node))
80
- assert_equal([:end], @job.state_transitions)
101
+ assert_equal([:end], @job.task_transitions)
81
102
 
82
- @job.state = "error_node"
103
+ @job.task = "error_node"
83
104
  assert_equal([], @job.transitions(:error_node))
84
- assert_equal([], @job.state_transitions)
105
+ assert_equal([], @job.task_transitions)
85
106
 
86
- @job.state = "timer_node"
107
+ @job.task = "timer_node"
87
108
  assert_equal([], @job.transitions(:timer_node))
88
- assert_equal([], @job.state_transitions)
109
+ assert_equal([], @job.task_transitions)
89
110
 
90
- @job.state = "task_node"
111
+ @job.task = "task_node"
91
112
  assert_equal([], @job.transitions(:task_node))
92
- assert_equal([], @job.state_transitions)
113
+ assert_equal([], @job.task_transitions)
93
114
 
94
- @job.state = "end"
115
+ @job.task = "end"
95
116
  assert_equal([], @job.transitions(:end))
96
- assert_equal([], @job.state_transitions)
117
+ assert_equal([], @job.task_transitions)
97
118
  end
98
119
 
99
- test "should raise a state not found error" do
100
- error = assert_raise(StateNotFound) { @job.transitions(:unknown_state) }
101
- assert_match("unknown_state", error.message)
120
+ test "should raise a task not found error" do
121
+ error = assert_raise(TaskNotFound) { @job.transitions(:unknown_task) }
122
+ assert_match("unknown_task", error.message)
102
123
  end
103
124
 
104
125
  test "should set the started_at attribute when starting a job" do
@@ -107,10 +128,10 @@ module LevelUp
107
128
  assert_not_nil(@job.started_at)
108
129
  end
109
130
 
110
- test "should change state" do
111
- assert_equal(true, @job.state?(:start))
131
+ test "should change task" do
132
+ assert_equal(true, @job.task?(:start))
112
133
  @job.boot!
113
- assert_equal(true, @job.state?(:end))
134
+ assert_equal(true, @job.task?(:end))
114
135
  end
115
136
 
116
137
  test "should set the end_at attribute when ending a job" do
@@ -125,7 +146,7 @@ module LevelUp
125
146
  assert_nil(@job.failed_in)
126
147
  assert_nil(@job.backtrace)
127
148
 
128
- @job.state = "error_node"
149
+ @job.task = "error_node"
129
150
  @job.boot!
130
151
  assert_equal(true, @job.error)
131
152
  assert_not_nil(@job.failed_at)
@@ -133,12 +154,34 @@ module LevelUp
133
154
  assert_not_nil(@job.backtrace)
134
155
  end
135
156
 
136
- test "should set the timer attribute when retrying a state" do
157
+ test "should set the backtrace attribute with the default backtrace size when rescuing from an error" do
158
+ @job.task = "error_node"
159
+ @job.boot!
160
+ assert_not_nil(@job.backtrace)
161
+ assert_equal(true, @job.backtrace.size <= Configuration::DEFAULT_BACKTRACE_SIZE)
162
+ end
163
+
164
+ test "should set the backtrace attribute with a custom backtrace size of 1 when rescuing from an error" do
165
+ Rails.configuration.level_up.backtrace_size = 1
166
+ @job.task = "error_node"
167
+ @job.boot!
168
+ assert_not_nil(@job.backtrace)
169
+ assert_equal(true, @job.backtrace.size <= Configuration.backtrace_size)
170
+ end
171
+
172
+ test "should not set the backtrace attribute with a custom backtrace size of 0 when rescuing from an error" do
173
+ Rails.configuration.level_up.backtrace_size = 0
174
+ @job.task = "error_node"
175
+ @job.boot!
176
+ assert_nil(@job.backtrace)
177
+ end
178
+
179
+ test "should set the timer attribute when retrying a task" do
137
180
  assert_equal(false, @job.timer)
138
181
  assert_nil(@job.retry_at)
139
182
  assert_nil(@job.delayed_job_id)
140
183
 
141
- @job.state = "timer_node"
184
+ @job.task = "timer_node"
142
185
  @job.boot!
143
186
  assert_equal(true, @job.timer)
144
187
  assert_not_nil(@job.retry_at)
@@ -146,31 +189,31 @@ module LevelUp
146
189
  end
147
190
 
148
191
  test "should set the task and description attributes when falling in human manual task" do
149
- assert_equal(false, @job.task)
150
- assert_nil(@job.task_description)
192
+ assert_equal(false, @job.manual_task)
193
+ assert_nil(@job.manual_task_description)
151
194
 
152
- @job.state = "task_node"
195
+ @job.task = "task_node"
153
196
  @job.boot!
154
- assert_equal(true, @job.task)
155
- assert_not_nil(@job.task_description)
197
+ assert_equal(true, @job.manual_task)
198
+ assert_not_nil(@job.manual_task_description)
156
199
  end
157
200
 
158
201
  test "should disallow transition" do
159
- assert_equal(true, @job.state?(:start))
202
+ assert_equal(true, @job.task?(:start))
160
203
  @job.event!(nil, false)
161
- assert_equal(true, @job.state?(:start))
204
+ assert_equal(true, @job.task?(:start))
162
205
  end
163
206
 
164
207
  test "should allow transition" do
165
- assert_equal(true, @job.state?(:start))
208
+ assert_equal(true, @job.task?(:start))
166
209
  @job.event!(nil, true)
167
- assert_equal(true, @job.state?(:end))
210
+ assert_equal(true, @job.task?(:end))
168
211
  end
169
212
 
170
213
  test "should disallow retry" do
171
214
  assert_equal(false, @job.timer)
172
215
  assert_nil(@job.retry_at)
173
- @job.state = "timer_node"
216
+ @job.task = "timer_node"
174
217
 
175
218
  @job.event!(nil, true, false)
176
219
  assert_equal(false, @job.timer)
@@ -181,7 +224,7 @@ module LevelUp
181
224
  test "should allow retry" do
182
225
  assert_equal(false, @job.timer)
183
226
  assert_nil(@job.retry_at)
184
- @job.state = "timer_node"
227
+ @job.task = "timer_node"
185
228
 
186
229
  @job.event!(nil, true, true)
187
230
  assert_equal(true, @job.timer)
@@ -204,5 +247,34 @@ module LevelUp
204
247
  @job.unqueue!
205
248
  assert_nil(@job.delayed_job_id)
206
249
  end
250
+
251
+ test "should have custom task classes" do
252
+ assert_equal(true, @custom_task_job.class.task_classes.key?(:start))
253
+ assert_equal("CustomNode", @custom_task_job.class.task_classes[:start])
254
+ assert_equal(true, @custom_task_job.class.task_classes.key?(:first_node))
255
+ assert_equal("CustomNode", @custom_task_job.class.task_classes[:first_node])
256
+ assert_equal(true, @custom_task_job.class.task_classes.key?(:cancel))
257
+ assert_equal("CustomNode", @custom_task_job.class.task_classes[:cancel])
258
+ assert_equal(true, @custom_task_job.class.task_classes.key?(:end))
259
+ assert_equal("CustomNode", @custom_task_job.class.task_classes[:end])
260
+ end
261
+
262
+ test "should use the custom task and raise an error" do
263
+ %w[start end cancel].each do
264
+ @custom_task_job.clear!(nil)
265
+ assert_equal(false, @custom_task_job.error)
266
+ @custom_task_job.boot!
267
+ assert_equal(true, @custom_task_job.error)
268
+ assert_equal("start", @custom_task_job.failed_in)
269
+ end
270
+ end
271
+
272
+ test "should not use the custom task when a task method is defined" do
273
+ assert_equal(false, @custom_task_job.error)
274
+ @custom_task_job.task = "first_node"
275
+ @custom_task_job.boot!
276
+ assert_equal(false, @custom_task_job.error)
277
+ assert_equal(true, @custom_task_job.task?(:first_node))
278
+ end
207
279
  end
208
280
  end