rails_workflow 0.2.0 → 0.2.1

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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/app/assets/javascripts/{workflow → rails_workflow}/application.js +0 -0
  4. data/app/assets/stylesheets/{workflow → rails_workflow}/application.css +0 -0
  5. data/app/concerns/{workflow → rails_workflow}/operation_status.rb +2 -2
  6. data/app/concerns/{workflow → rails_workflow}/operation_templates/assignments.rb +4 -4
  7. data/app/concerns/{workflow → rails_workflow}/operation_templates/default_builder.rb +3 -3
  8. data/app/concerns/{workflow → rails_workflow}/operation_templates/dependencies.rb +1 -2
  9. data/app/concerns/{workflow → rails_workflow}/operations/assignments.rb +3 -4
  10. data/app/concerns/{workflow → rails_workflow}/operations/default_runner.rb +8 -8
  11. data/app/concerns/{workflow → rails_workflow}/operations/dependencies.rb +2 -2
  12. data/app/concerns/{workflow → rails_workflow}/process_status.rb +2 -2
  13. data/app/concerns/{workflow → rails_workflow}/process_templates/default_builder.rb +2 -2
  14. data/app/concerns/{workflow → rails_workflow}/processes/default_runner.rb +2 -3
  15. data/app/concerns/{workflow → rails_workflow}/processes/dependency_resolver.rb +2 -3
  16. data/app/concerns/{workflow → rails_workflow}/user/assignment.rb +2 -3
  17. data/app/controllers/rails_workflow/application_controller.rb +10 -0
  18. data/app/controllers/{workflow → rails_workflow}/errors_controller.rb +2 -2
  19. data/app/controllers/{workflow → rails_workflow}/operation_templates_controller.rb +5 -6
  20. data/app/controllers/{workflow → rails_workflow}/operations_controller.rb +5 -5
  21. data/app/controllers/{workflow → rails_workflow}/process_templates_controller.rb +4 -5
  22. data/app/controllers/{workflow → rails_workflow}/processes_controller.rb +10 -11
  23. data/app/decorators/{workflow → rails_workflow}/context_decorator.rb +1 -1
  24. data/app/decorators/{workflow → rails_workflow}/decorator.rb +1 -1
  25. data/app/decorators/{workflow → rails_workflow}/operation_decorator.rb +3 -3
  26. data/app/decorators/{workflow → rails_workflow}/operation_helper_decorator.rb +1 -2
  27. data/app/decorators/{workflow → rails_workflow}/operation_template_decorator.rb +1 -2
  28. data/app/decorators/{workflow → rails_workflow}/paginating_decorator.rb +1 -1
  29. data/app/decorators/{workflow → rails_workflow}/process_decorator.rb +1 -4
  30. data/app/decorators/{workflow → rails_workflow}/process_template_decorator.rb +4 -5
  31. data/app/decorators/{workflow → rails_workflow}/status_decorator.rb +1 -2
  32. data/app/helpers/{workflow → rails_workflow}/application_helper.rb +1 -1
  33. data/app/managers/{workflow → rails_workflow}/process_manager.rb +3 -4
  34. data/app/models/{workflow → rails_workflow}/context.rb +1 -1
  35. data/app/models/{workflow → rails_workflow}/error.rb +14 -14
  36. data/app/models/{workflow → rails_workflow}/operation.rb +6 -7
  37. data/app/models/{workflow → rails_workflow}/operation_template.rb +7 -8
  38. data/app/models/{workflow → rails_workflow}/process.rb +8 -9
  39. data/app/models/{workflow → rails_workflow}/process_template.rb +3 -4
  40. data/app/models/{workflow → rails_workflow}/user_by_group_operation.rb +1 -2
  41. data/app/models/{workflow → rails_workflow}/user_by_role_operation.rb +1 -2
  42. data/app/views/layouts/{workflow → rails_workflow}/application.html.slim +3 -3
  43. data/app/views/{workflow → rails_workflow}/operation_templates/_default_form.html.slim +0 -0
  44. data/app/views/{workflow → rails_workflow}/operation_templates/_user_group_form.html.slim +0 -0
  45. data/app/views/{workflow → rails_workflow}/operation_templates/_user_role_form.html.slim +0 -0
  46. data/app/views/{workflow → rails_workflow}/operation_templates/edit.html.slim +0 -0
  47. data/app/views/{workflow → rails_workflow}/operation_templates/index.html.slim +1 -1
  48. data/app/views/{workflow → rails_workflow}/operation_templates/new.html.slim +0 -0
  49. data/app/views/{workflow → rails_workflow}/operation_templates/show.html.slim +0 -0
  50. data/app/views/{workflow → rails_workflow}/operations/index.html.slim +0 -0
  51. data/app/views/{workflow → rails_workflow}/operations/show.html.slim +0 -0
  52. data/app/views/{workflow → rails_workflow}/process_templates/_form.html.slim +0 -0
  53. data/app/views/{workflow → rails_workflow}/process_templates/edit.html.slim +0 -0
  54. data/app/views/{workflow → rails_workflow}/process_templates/index.html.slim +0 -0
  55. data/app/views/{workflow → rails_workflow}/process_templates/new.html.slim +0 -0
  56. data/app/views/{workflow → rails_workflow}/process_templates/show.html.slim +1 -1
  57. data/app/views/{workflow → rails_workflow}/processes/_form.html.slim +0 -0
  58. data/app/views/{workflow → rails_workflow}/processes/edit.html.slim +0 -0
  59. data/app/views/{workflow → rails_workflow}/processes/index.html.slim +6 -6
  60. data/app/views/{workflow → rails_workflow}/processes/new.html.slim +0 -0
  61. data/app/views/{workflow → rails_workflow}/processes/show.html.slim +0 -0
  62. data/app/workers/{workflow → rails_workflow}/error_worker.rb +5 -5
  63. data/app/workers/{workflow → rails_workflow}/operation_worker.rb +1 -1
  64. data/config/initializers/{workflow.rb → rails_workflow.rb} +8 -8
  65. data/config/routes.rb +1 -1
  66. data/db/migrate/20150210070051_change_namespace.rb +10 -0
  67. data/lib/generators/{workflow → rails_workflow}/install/install_generator.rb +1 -1
  68. data/lib/generators/{workflow → rails_workflow}/install/templates/create_workflow_processes.rb +22 -12
  69. data/lib/{workflow → rails_workflow}/engine.rb +2 -8
  70. data/lib/rails_workflow/version.rb +3 -0
  71. data/lib/{workflow.rb → rails_workflow.rb} +9 -9
  72. data/lib/tasks/{workflow_tasks.rake → rails_workflow_tasks.rake} +0 -0
  73. data/spec/controllers/{workflow → rails_workflow}/operation_templates_controller_spec.rb +6 -6
  74. data/spec/controllers/{workflow → rails_workflow}/operations_controller_spec.rb +2 -2
  75. data/spec/controllers/{workflow → rails_workflow}/process_templates_controller_spec.rb +2 -2
  76. data/spec/controllers/{workflow → rails_workflow}/processes_controller_spec.rb +2 -2
  77. data/spec/core/{worklow → rails_workflow}/process_manager_spec.rb +11 -11
  78. data/spec/dummy/app/controllers/sales_contacts_controller.rb +1 -1
  79. data/spec/dummy/app/models/bad_operation.rb +1 -1
  80. data/spec/dummy/app/models/bad_operation_template.rb +1 -1
  81. data/spec/dummy/app/models/user.rb +1 -1
  82. data/spec/dummy/config/application.rb +1 -1
  83. data/spec/dummy/config/initializers/workflow.rb +1 -1
  84. data/spec/dummy/config/routes.rb +1 -1
  85. data/spec/dummy/db/schema.rb +34 -34
  86. data/spec/dummy/log/development.log +1324 -0
  87. data/spec/dummy/log/test.log +7697 -0
  88. data/spec/dummy/tmp/cache/assets/development/sprockets/0aeea3efe13c49227e4f05894224629b +0 -0
  89. data/spec/dummy/tmp/cache/assets/development/sprockets/17093127c2a964b159dacb6baee0c707 +0 -0
  90. data/spec/dummy/tmp/cache/assets/development/sprockets/844434b6c7324d1785e26864aee28316 +0 -0
  91. data/spec/dummy/tmp/cache/assets/development/sprockets/ab0c70eaae03da94a23f832513ff652b +0 -0
  92. data/spec/dummy/tmp/cache/assets/development/sprockets/d8f3150c250e5b7c730f1c8b883bf033 +0 -0
  93. data/spec/dummy/tmp/cache/assets/development/sprockets/f794c7b05987535f7000622afe6630d1 +0 -0
  94. data/spec/dummy/tmp/pids/server.pid +1 -0
  95. data/spec/factories/context.rb +1 -1
  96. data/spec/factories/operation_templates.rb +1 -1
  97. data/spec/factories/operations.rb +3 -3
  98. data/spec/factories/process_templates.rb +1 -1
  99. data/spec/factories/processes.rb +2 -2
  100. data/spec/factories/workflow_errors.rb +1 -1
  101. data/spec/features/process_template_spec.rb +0 -1
  102. data/spec/models/{workflow → rails_workflow}/context_spec.rb +4 -4
  103. data/spec/models/{workflow → rails_workflow}/error_spec.rb +1 -1
  104. data/spec/models/{workflow → rails_workflow}/operation_spec.rb +19 -19
  105. data/spec/models/{workflow → rails_workflow}/operation_template_spec.rb +5 -5
  106. data/spec/models/{workflow → rails_workflow}/process_spec.rb +1 -1
  107. data/spec/models/{workflow → rails_workflow}/process_template_spec.rb +3 -3
  108. data/spec/rails_helper.rb +2 -2
  109. data/spec/support/{workflow → rails_workflow}/custom_operation.rb +1 -1
  110. data/spec/support/{workflow → rails_workflow}/custom_operation_template.rb +1 -1
  111. metadata +111 -96
  112. data/app/controllers/workflow/application_controller.rb +0 -10
  113. data/lib/workflow/version.rb +0 -3
@@ -1,18 +1,17 @@
1
- # todo cover by tests
2
- module Workflow
1
+ module RailsWorkflow
3
2
  class OperationTemplate < ActiveRecord::Base
4
3
  include OperationStatus
5
4
  include OperationTemplates::Dependencies
6
5
  include OperationTemplates::Assignments
7
6
  include OperationTemplates::DefaultBuilder
8
7
 
9
- belongs_to :process_template, class_name: 'Workflow::ProcessTemplate'
10
- belongs_to :child_process, class_name: 'Workflow::ProcessTemplate'
8
+ belongs_to :process_template, class_name: "RailsWorkflow::ProcessTemplate"
9
+ belongs_to :child_process, class_name: "RailsWorkflow::ProcessTemplate"
11
10
 
12
11
  class << self
13
12
 
14
13
  def types
15
- Workflow.config.operation_types
14
+ RailsWorkflow.config.operation_types
16
15
  end
17
16
 
18
17
  # by default system using context data of first dependnecy
@@ -22,7 +21,7 @@ module Workflow
22
21
  end
23
22
 
24
23
  def build_context! operation, dependencies
25
- Workflow::Context.new(
24
+ RailsWorkflow::Context.new(
26
25
  parent: operation,
27
26
  data: build_context(dependencies) || operation.process.data)
28
27
  end
@@ -36,7 +35,7 @@ module Workflow
36
35
  end
37
36
 
38
37
  def default_type
39
- Workflow.config.default_operation_template_type
38
+ RailsWorkflow.config.default_operation_template_type
40
39
  end
41
40
 
42
41
  def resolve_dependency operation
@@ -49,7 +48,7 @@ module Workflow
49
48
 
50
49
  private
51
50
  def default_class kind
52
- Workflow.config.operation_types[kind][:class]
51
+ RailsWorkflow.config.operation_types[kind][:class]
53
52
  end
54
53
 
55
54
  def get_class symb, default
@@ -1,15 +1,14 @@
1
- # todo cover by tests
2
- module Workflow
1
+ module RailsWorkflow
3
2
  class Process < ActiveRecord::Base
4
3
  include ProcessStatus
5
4
  include Processes::DependencyResolver
6
5
  include Processes::DefaultRunner
7
6
 
8
- belongs_to :template, class_name: 'Workflow::ProcessTemplate'
9
- has_many :operations, class_name: 'Workflow::Operation'
10
- has_one :parent_operation, class_name: 'Workflow::Operation', foreign_key: :child_process_id
11
- has_one :context, class_name: 'Workflow::Context', as: :parent
12
- has_many :workflow_errors, class_name: "Workflow::Error", as: :parent
7
+ belongs_to :template, class_name: "RailsWorkflow::ProcessTemplate"
8
+ has_many :operations, class_name: "RailsWorkflow::Operation"
9
+ has_one :parent_operation, class_name: "RailsWorkflow::Operation", foreign_key: :child_process_id
10
+ has_one :context, class_name: "RailsWorkflow::Context", as: :parent
11
+ has_many :workflow_errors, class_name: "RailsWorkflow::Error", as: :parent
13
12
 
14
13
  delegate :data, to: :context
15
14
  scope :by_status, -> (status) { where(status: status) }
@@ -22,13 +21,13 @@ module Workflow
22
21
  query = 'select status, cnt from (
23
22
  select row_number() over (partition by status),
24
23
  count(*) over (partition by status) cnt,
25
- status from workflow_processes)t
24
+ status from rails_workflow_processes)t
26
25
  where row_number = 1'
27
26
 
28
27
 
29
28
  statuses = connection.select_all(query).rows
30
29
 
31
- (Workflow::Process::NOT_STARTED..Workflow::Process::ROLLBACK).to_a.map{|status|
30
+ (RailsWorkflow::Process::NOT_STARTED..RailsWorkflow::Process::ROLLBACK).to_a.map{|status|
32
31
  statuses.detect{|s| s.first.to_i == status }.try(:last).to_i
33
32
  }
34
33
 
@@ -1,5 +1,4 @@
1
- # todo cover by tests
2
- module Workflow
1
+ module RailsWorkflow
3
2
  class ProcessTemplate < ActiveRecord::Base
4
3
  include ProcessTemplates::DefaultBuilder
5
4
 
@@ -15,12 +14,12 @@ module Workflow
15
14
  # and set default Workflow::Process if blank process_class on template
16
15
  def process_class
17
16
  get_class_for :process_class,
18
- Workflow.config.process_class
17
+ RailsWorkflow.config.process_class
19
18
  end
20
19
 
21
20
  def manager_class
22
21
  get_class_for(:manager_class,
23
- Workflow.config.manager_class)
22
+ RailsWorkflow.config.manager_class)
24
23
  end
25
24
 
26
25
  def independent_operations
@@ -1,5 +1,4 @@
1
- # todo cover by tests
2
- module Workflow
1
+ module RailsWorkflow
3
2
  class UserByGroupOperation < Operation
4
3
 
5
4
  def can_start?
@@ -1,5 +1,4 @@
1
- # todo cover by tests
2
- module Workflow
1
+ module RailsWorkflow
3
2
  class UserByRoleOperation < Operation
4
3
 
5
4
  def can_start?
@@ -7,8 +7,8 @@ head
7
7
 
8
8
  title Rails Workflow Engine
9
9
 
10
- = stylesheet_link_tag "workflow/application"
11
- = javascript_include_tag "workflow/application"
10
+ = stylesheet_link_tag "rails_workflow/application"
11
+ = javascript_include_tag "rails_workflow/application"
12
12
  = csrf_meta_tags
13
13
 
14
14
  a href="#Top"
@@ -48,4 +48,4 @@ body
48
48
  | &nbsp;&bull;
49
49
  span<>= mail_to "max.madzhuga@gmail.com", "Contact me", subject: "Workflow Support"
50
50
  | &bull;
51
- span<>= link_to "Workflow Development Blog", 'http://madzhuga.tumblr.com'
51
+ span<>= link_to "Rails Workflow Site", 'http://madzhuga.github.io/rails_workflow/'
@@ -65,7 +65,7 @@ ol.breadcrumb.alert-warning
65
65
  | Add Operation
66
66
  span.caret<>
67
67
  ul.dropdown-menu role="menu"
68
- - Workflow::OperationTemplate.types.each do |type, value|
68
+ - RailsWorkflow::OperationTemplate.types.each do |type, value|
69
69
  li
70
70
  = link_to value[:title], new_template_path.call(type)
71
71
 
@@ -48,7 +48,7 @@ ol.breadcrumb.alert-warning
48
48
  | Add Operation
49
49
  span.caret<>
50
50
  ul.dropdown-menu role="menu"
51
- - Workflow::OperationTemplate.types.each do |type, value|
51
+ - RailsWorkflow::OperationTemplate.types.each do |type, value|
52
52
  li
53
53
  = link_to value[:title], new_template_path.call(type)
54
54
 
@@ -14,19 +14,19 @@ ol.breadcrumb.alert-warning
14
14
  span.badge< = @statistic[:all]
15
15
  = link_to processes_path(filter: {status: "in_progress"}), class: "btn btn-primary" do
16
16
  | In progress
17
- span.badge< = @statistic[:statuses][Workflow::Process::IN_PROGRESS]
17
+ span.badge< = @statistic[:statuses][RailsWorkflow::Process::IN_PROGRESS]
18
18
  = link_to processes_path(filter: {status: "done"}), class: "btn btn-success" do
19
19
  | Done
20
- span.badge< = @statistic[:statuses][Workflow::Process::DONE]
20
+ span.badge< = @statistic[:statuses][RailsWorkflow::Process::DONE]
21
21
  = link_to processes_path(filter: {status: "waiting"}), class: "btn btn-info" do
22
22
  | Waiting
23
- span.badge< = @statistic[:statuses][Workflow::Process::WAITING]
23
+ span.badge< = @statistic[:statuses][RailsWorkflow::Process::WAITING]
24
24
  = link_to processes_path(filter: {status: "not_started"}), class: "btn btn-warning" do
25
25
  | Not Started
26
- span.badge< = @statistic[:statuses][Workflow::Process::NOT_STARTED]
26
+ span.badge< = @statistic[:statuses][RailsWorkflow::Process::NOT_STARTED]
27
27
  = link_to processes_path(filter: {status: "error"}), class: "btn btn-danger" do
28
28
  | Error
29
- span.badge< = @statistic[:statuses][Workflow::Process::ERROR]
29
+ span.badge< = @statistic[:statuses][RailsWorkflow::Process::ERROR]
30
30
 
31
31
  table.table.table-striped.table-hover
32
32
  thead
@@ -72,7 +72,7 @@ ol.breadcrumb.alert-warning
72
72
  tbody
73
73
  - @errors.each do |error|
74
74
  tr
75
- - if error.parent.is_a? Workflow::Operation
75
+ - if error.parent.is_a? RailsWorkflow::Operation
76
76
  td = link_to error.message, process_operation_path(error.parent.process, error.parent)
77
77
  - else
78
78
  td = link_to error.message, process_path(error.parent)
@@ -1,15 +1,15 @@
1
- module Workflow
1
+ module RailsWorkflow
2
2
  class ErrorWorker
3
3
  include Sidekiq::Worker
4
4
 
5
5
  def perform(parent_id, parent_class)
6
6
  parent = parent_class.constantize.find(parent_id)
7
7
 
8
- if parent.is_a? Workflow::Operation
9
- parent.status = Workflow::Operation::ERROR
8
+ if parent.is_a? RailsWorkflow::Operation
9
+ parent.status = RailsWorkflow::Operation::ERROR
10
10
  end
11
- if parent.is_a? Workflow::Process
12
- parent.status = Workflow::Process::ERROR
11
+ if parent.is_a? RailsWorkflow::Process
12
+ parent.status = RailsWorkflow::Process::ERROR
13
13
  end
14
14
 
15
15
  parent.save
@@ -1,4 +1,4 @@
1
- module Workflow
1
+ module RailsWorkflow
2
2
  class OperationWorker
3
3
  include Sidekiq::Worker
4
4
 
@@ -14,7 +14,7 @@ class ActionController::Base
14
14
 
15
15
  if @current_workflow_operation &&
16
16
  @current_workflow_operation.id == operation_id
17
- Workflow::Operation.user_ready_statuses.include? @current_workflow_operation.status
17
+ RailsWorkflow::Operation.user_ready_statuses.include? @current_workflow_operation.status
18
18
 
19
19
  @current_workflow_operation
20
20
 
@@ -22,9 +22,9 @@ class ActionController::Base
22
22
 
23
23
  @current_workflow_operation = begin
24
24
 
25
- if Workflow::Operation.exists?(id: operation_id, status: Workflow::Operation::WAITING)
26
- operation = Workflow::Operation.find(operation_id)
27
- Workflow::OperationHelperDecorator.decorate(operation)
25
+ if RailsWorkflow::Operation.exists?(id: operation_id, status: RailsWorkflow::Operation::WAITING)
26
+ operation = RailsWorkflow::Operation.find(operation_id)
27
+ RailsWorkflow::OperationHelperDecorator.decorate(operation)
28
28
  else
29
29
  clear_current_operation
30
30
  end
@@ -37,14 +37,14 @@ class ActionController::Base
37
37
  helper_method :current_operation
38
38
 
39
39
  def available_operations
40
- operations = Workflow::Operation.available_for_user(current_user)
41
- Workflow::OperationHelperDecorator.decorate_collection(operations)
40
+ operations = RailsWorkflow::Operation.available_for_user(current_user)
41
+ RailsWorkflow::OperationHelperDecorator.decorate_collection(operations)
42
42
  end
43
43
  helper_method :available_operations
44
44
 
45
45
  def assigned_operations
46
- operations = Workflow::Operation.assigned_to(current_user).waiting
47
- Workflow::OperationHelperDecorator.decorate_collection(operations)
46
+ operations = RailsWorkflow::Operation.assigned_to(current_user).waiting
47
+ RailsWorkflow::OperationHelperDecorator.decorate_collection(operations)
48
48
  end
49
49
  helper_method :assigned_operations
50
50
 
data/config/routes.rb CHANGED
@@ -1,4 +1,4 @@
1
- Workflow::Engine.routes.draw do
1
+ RailsWorkflow::Engine.routes.draw do
2
2
 
3
3
  resources :operations do
4
4
  member do
@@ -0,0 +1,10 @@
1
+ class ChangeNamespace < ActiveRecord::Migration
2
+ def change
3
+ rename_table :workflow_processes, :rails_workflow_processes
4
+ rename_table :workflow_operations, :rails_workflow_operations
5
+ rename_table :workflow_process_templates, :rails_workflow_process_templates
6
+ rename_table :workflow_operation_templates, :rails_workflow_operation_templates
7
+ rename_table :workflow_contexts, :rails_workflow_contexts
8
+ rename_table :workflow_errors, :rails_workflow_errors
9
+ end
10
+ end
@@ -1,6 +1,6 @@
1
1
  require 'rails/generators/migration'
2
2
 
3
- module Workflow
3
+ module RailsWorkflow
4
4
  module Generators
5
5
  class InstallGenerator < ::Rails::Generators::Base
6
6
  include Rails::Generators::Migration
@@ -1,6 +1,6 @@
1
1
  class CreateWorkflowProcesses < ActiveRecord::Migration
2
2
  def change
3
- unless table_exists? :workflow_processes
3
+ unless table_exists?(:rails_workflow_processes) || table_exists?(:workflow_processes)
4
4
  create_table :workflow_processes do |t|
5
5
  t.integer :status
6
6
  t.boolean :async
@@ -84,22 +84,32 @@ class CreateWorkflowProcesses < ActiveRecord::Migration
84
84
  add_column :workflow_operation_templates, :is_background, :boolean, default: true
85
85
  add_column :workflow_operations, :is_background, :boolean
86
86
 
87
- end
87
+ unless column_exists? :workflow_operation_templates, :type
88
+ add_column :workflow_operation_templates, :type, :string
89
+ end
88
90
 
89
- unless column_exists? :workflow_operation_templates, :type
90
- add_column :workflow_operation_templates, :type, :string
91
- end
91
+ unless column_exists? :workflow_errors, :resolved
92
+ add_column :workflow_errors, :resolved, :boolean
93
+ end
92
94
 
93
- unless column_exists? :workflow_errors, :resolved
94
- add_column :workflow_errors, :resolved, :boolean
95
- end
95
+ unless column_exists? :workflow_process_templates, :type
96
+ add_column :workflow_process_templates, :type, :string
97
+ end
98
+
99
+ unless column_exists? :workflow_errors, :resolved, :boolean
100
+ add_column :workflow_errors, :resolved, :boolean
101
+ end
96
102
 
97
- unless column_exists? :workflow_process_templates, :type
98
- add_column :workflow_process_templates, :type, :string
99
103
  end
100
104
 
101
- unless column_exists? :workflow_errors, :resolved, :boolean
102
- add_column :workflow_errors, :resolved, :boolean
105
+
106
+ unless table_exists? :rails_workflow_processes
107
+ rename_table :workflow_processes, :rails_workflow_processes
108
+ rename_table :workflow_operations, :rails_workflow_operations
109
+ rename_table :workflow_process_templates, :rails_workflow_process_templates
110
+ rename_table :workflow_operation_templates, :rails_workflow_operation_templates
111
+ rename_table :workflow_contexts, :rails_workflow_contexts
112
+ rename_table :workflow_errors, :rails_workflow_errors
103
113
  end
104
114
 
105
115
  end
@@ -1,6 +1,6 @@
1
- module Workflow
1
+ module RailsWorkflow
2
2
  class Engine < ::Rails::Engine
3
- isolate_namespace Workflow
3
+ isolate_namespace RailsWorkflow
4
4
 
5
5
  config.generators do |g|
6
6
  g.template_engine :slim
@@ -10,12 +10,6 @@ module Workflow
10
10
  g.helper false
11
11
  end
12
12
 
13
- # initializer "workflow.url_helpers" do
14
- # ActiveSupport.on_load(:action_controller) do
15
- # helper Rails.application.routes.url_helpers
16
- # end
17
- # end
18
-
19
13
  initializer :append_migrations do |app|
20
14
  unless app.root.to_s.match root.to_s
21
15
  config.paths["db/migrate"].expanded.each do |expanded_path|
@@ -0,0 +1,3 @@
1
+ module RailsWorkflow
2
+ VERSION = "0.2.1"
3
+ end
@@ -1,11 +1,11 @@
1
- require "workflow/engine"
1
+ require "rails_workflow/engine"
2
2
  require 'singleton'
3
3
  require 'inherited_resources'
4
4
  require 'devise'
5
5
  require 'draper'
6
6
 
7
7
 
8
- module Workflow
8
+ module RailsWorkflow
9
9
 
10
10
  def self.config
11
11
  Config.instance
@@ -21,22 +21,22 @@ module Workflow
21
21
  @default_operation_types = {
22
22
  default: {
23
23
  title: "Default Operation",
24
- class: "Workflow::Operation"
24
+ class: "RailsWorkflow::Operation"
25
25
  },
26
26
  user_role: {
27
27
  title: "Operation for User By Role",
28
- class: "Workflow::UserByRoleOperation"
28
+ class: "RailsWorkflow::UserByRoleOperation"
29
29
  },
30
30
  user_group: {
31
31
  title: "Operation by User Group",
32
- class: "Workflow::UserByGroupOperation"
32
+ class: "RailsWorkflow::UserByGroupOperation"
33
33
  }
34
34
  }
35
35
 
36
- @default_operation_template_type = "Workflow::OperationTemplate"
37
- @default_process_manager = "Workflow::ProcessManager"
38
- @default_process_class = "Workflow::Process"
39
- @default_process_template_type = "Workflow::ProcessTemplate"
36
+ @default_operation_template_type = "RailsWorkflow::OperationTemplate"
37
+ @default_process_manager = "RailsWorkflow::ProcessManager"
38
+ @default_process_class = "RailsWorkflow::Process"
39
+ @default_process_template_type = "RailsWorkflow::ProcessTemplate"
40
40
  @default_assignment_by = [:group, :role]
41
41
 
42
42
 
@@ -1,8 +1,8 @@
1
1
  require 'rails_helper'
2
2
 
3
- module Workflow
3
+ module RailsWorkflow
4
4
  RSpec.describe OperationTemplatesController, :type => :controller do
5
- routes { Workflow::Engine.routes }
5
+ routes { RailsWorkflow::Engine.routes }
6
6
  login_user
7
7
 
8
8
  before :each do
@@ -13,7 +13,7 @@ module Workflow
13
13
  {
14
14
  title: 'First Test project',
15
15
  process_template_id: @template.id,
16
- type: 'Workflow::OperationTemplate'
16
+ type: 'RailsWorkflow::OperationTemplate'
17
17
  }
18
18
  }
19
19
 
@@ -79,7 +79,7 @@ module Workflow
79
79
  it "creates a new CustomOperationTemplate" do
80
80
 
81
81
  attrs = valid_attributes
82
- attrs[:type] = "Workflow::CustomOperationTemplate"
82
+ attrs[:type] = "RailsWorkflow::CustomOperationTemplate"
83
83
  expect {
84
84
  post :create, {
85
85
  process_template_id: @template.id,
@@ -88,7 +88,7 @@ module Workflow
88
88
  }.to change(OperationTemplate, :count).by(1)
89
89
 
90
90
  last_operation = OperationTemplate.last
91
- expect(last_operation).to be_instance_of(Workflow::CustomOperationTemplate)
91
+ expect(last_operation).to be_instance_of(RailsWorkflow::CustomOperationTemplate)
92
92
  end
93
93
 
94
94
  it "assigns a newly created operation_template as @operation_template" do
@@ -144,7 +144,7 @@ module Workflow
144
144
  id: operation_template.to_param,
145
145
  operation_template: valid_attributes},
146
146
  valid_session, use_route: :workflow
147
- # todo: fix to check for changes
147
+
148
148
  # expect(assigns(:operations)).to eq([operation_template])
149
149
  end
150
150
 
@@ -18,9 +18,9 @@ require 'rails_helper'
18
18
  # Message expectations are only used when there is no simpler way to specify
19
19
  # that an instance is receiving a specific message.
20
20
 
21
- module Workflow
21
+ module RailsWorkflow
22
22
  RSpec.describe OperationsController, :type => :controller do
23
- routes { Workflow::Engine.routes }
23
+ routes { RailsWorkflow::Engine.routes }
24
24
  login_user
25
25
 
26
26
  let(:valid_attributes) {
@@ -1,8 +1,8 @@
1
1
  require 'rails_helper'
2
2
 
3
- module Workflow
3
+ module RailsWorkflow
4
4
  RSpec.describe ProcessTemplatesController, :type => :controller do
5
- routes { Workflow::Engine.routes }
5
+ routes { RailsWorkflow::Engine.routes }
6
6
  login_user
7
7
 
8
8
  let(:valid_attributes) {
@@ -1,8 +1,8 @@
1
1
  require 'rails_helper'
2
2
 
3
- module Workflow
3
+ module RailsWorkflow
4
4
  RSpec.describe ProcessesController, :type => :controller do
5
- routes { Workflow::Engine.routes }
5
+ routes { RailsWorkflow::Engine.routes }
6
6
  login_user
7
7
 
8
8
  before :each do
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- module Workflow
3
+ module RailsWorkflow
4
4
  RSpec.describe ProcessManager, :type => :model do
5
5
 
6
6
  let(:template) {
@@ -10,7 +10,7 @@ module Workflow
10
10
  dependencies = [
11
11
  {
12
12
  "id" => operation.id,
13
- "statuses" => [Workflow::OperationStatus::DONE]
13
+ "statuses" => [RailsWorkflow::OperationStatus::DONE]
14
14
  }
15
15
  ]
16
16
 
@@ -28,7 +28,7 @@ module Workflow
28
28
  it 'should create new process' do
29
29
  expect(process).to_not be_nil
30
30
  expect(process).to be_kind_of(Process)
31
- expect(process.status).to eq Workflow::Process::NOT_STARTED
31
+ expect(process.status).to eq RailsWorkflow::Process::NOT_STARTED
32
32
  end
33
33
 
34
34
  it 'with reference to template' do
@@ -37,7 +37,7 @@ module Workflow
37
37
 
38
38
  it 'should create new process operations' do
39
39
  expect(process.operations.size).to eq 1
40
- expect(process.operations.first.status).to eq Workflow::Operation::NOT_STARTED
40
+ expect(process.operations.first.status).to eq RailsWorkflow::Operation::NOT_STARTED
41
41
  end
42
42
 
43
43
  it 'should create process context' do
@@ -54,30 +54,30 @@ module Workflow
54
54
  context 'start process' do
55
55
  context 'start process (in progres)' do
56
56
  before :each do
57
- allow_any_instance_of(Workflow::ProcessManager).to receive(:complete_process)
58
- allow_any_instance_of(Workflow::Operation).to receive(:complete)
59
- process_manager = Workflow::ProcessManager.new process
57
+ allow_any_instance_of(RailsWorkflow::ProcessManager).to receive(:complete_process)
58
+ allow_any_instance_of(RailsWorkflow::Operation).to receive(:complete)
59
+ process_manager = RailsWorkflow::ProcessManager.new process
60
60
  process_manager.start_process
61
61
  end
62
62
 
63
63
  it 'should start new process' do
64
- expect(process.status).to eq Workflow::Process::IN_PROGRESS
64
+ expect(process.status).to eq RailsWorkflow::Process::IN_PROGRESS
65
65
  end
66
66
 
67
67
  it 'should start first operations' do
68
- expect(process.operations.first.status).to eq Workflow::Operation::IN_PROGRESS
68
+ expect(process.operations.first.status).to eq RailsWorkflow::Operation::IN_PROGRESS
69
69
  end
70
70
  end
71
71
  end
72
72
 
73
73
  context 'complete operations' do
74
74
  let(:manager) {
75
- Workflow::ProcessManager.new process
75
+ RailsWorkflow::ProcessManager.new process
76
76
  }
77
77
 
78
78
  context 'dependent operation' do
79
79
  it 'should be created when dependencies is sutisfied' do
80
- allow_any_instance_of(Workflow::OperationTemplate).to receive(:resolve_dependency).and_return(false)
80
+ allow_any_instance_of(RailsWorkflow::OperationTemplate).to receive(:resolve_dependency).and_return(false)
81
81
  manager.start_process
82
82
  process.operations.first.complete
83
83
  expect(process.operations.size).to eq 1
@@ -7,7 +7,7 @@ class SalesContactsController < InheritedResources::Base
7
7
  #resource (sales contact) will still be created in the system
8
8
  #so it may be better to create process in the same transaction
9
9
  #if you need them both to be created or both crashed
10
- Workflow::ProcessManager.
10
+ RailsWorkflow::ProcessManager.
11
11
  start_process(
12
12
  18,
13
13
  {
@@ -1,4 +1,4 @@
1
- class BadOperation < Workflow::Operation
1
+ class BadOperation < RailsWorkflow::Operation
2
2
  def on_complete
3
3
  # raise 'ON_COMPLETE EXCEPTION'
4
4
  end
@@ -1,4 +1,4 @@
1
- class BadOperationTemplate < Workflow::OperationTemplate
1
+ class BadOperationTemplate < RailsWorkflow::OperationTemplate
2
2
  def build_operation operation
3
3
  # raise 'BUILD_OPERATION'
4
4
  end