mobile_workflow 0.7.7 → 0.9.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 (23) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/concerns/mobile_workflow/displayable/steps/form.rb +52 -42
  3. data/app/models/concerns/mobile_workflow/displayable/steps/stack.rb +9 -1
  4. data/app/models/concerns/mobile_workflow/displayable/steps/styled_content/stack.rb +4 -3
  5. data/config/initializers/add_frozen_string_literal.rb +19 -0
  6. data/lib/generators/mobile_workflow/install/install_generator.rb +5 -1
  7. data/lib/generators/mobile_workflow/install/templates/Gemfile.erb +24 -7
  8. data/lib/generators/mobile_workflow/install/templates/api_controller.rb.erb +1 -1
  9. data/lib/generators/mobile_workflow/install/templates/app/helpers/application_helper.rb +1 -2
  10. data/lib/generators/mobile_workflow/install/templates/{ability.rb → app/models/ability.rb} +1 -1
  11. data/lib/generators/mobile_workflow/install/templates/app/models/application_record.rb +2 -2
  12. data/lib/generators/mobile_workflow/install/templates/config/initializers/mobile_workflow_rollbar.rb +7 -0
  13. data/lib/generators/mobile_workflow/install/templates/deserializer_spec.rb.erb +0 -2
  14. data/lib/generators/mobile_workflow/install/templates/seeds.rb.erb +1 -1
  15. data/lib/generators/mobile_workflow/install/templates/sessions_controller.rb.erb +3 -4
  16. data/lib/generators/mobile_workflow/install/templates/user.rb.erb +2 -2
  17. data/lib/generators/mobile_workflow/templates/controller.rb.erb +3 -3
  18. data/lib/generators/mobile_workflow/templates/controller_spec.rb.erb +17 -9
  19. data/lib/generators/mobile_workflow/templates/model.rb.erb +2 -2
  20. data/lib/mobile_workflow/cli/app_builder.rb +21 -4
  21. data/lib/mobile_workflow/cli/app_server_generator.rb +3 -1
  22. data/lib/mobile_workflow/version.rb +1 -1
  23. metadata +10 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf9a3d0ae2752b171aea1043b7cc57a8425b80ecf086bb226faadffb936fd5ee
4
- data.tar.gz: 1d0c4bf77cbbb66844a58a4d94bfb5532f4706a4a5fa2ae02f01e1e0f72e4939
3
+ metadata.gz: 948c45e0602fe9441f2cd0c79e4b4141c9ed357b9489ca7f3f1af599ea370c66
4
+ data.tar.gz: c84792530d7b0c02a05cc6e6d253e1464e7edea71b4f00e66d290d3a45221ccd
5
5
  SHA512:
6
- metadata.gz: e3c1748bdbe2b84415e434632080968cc02fb4e6e7b5a248bf8d979868b74714ce89c0d04165207d3b67008e45b3f08e4b84f67124a128f971627ad28611591f
7
- data.tar.gz: 90329d6e78a89c601fa6bb5cc62b4d856b9ba264e56d6bfe83b7e1afc5ea5d1849355ccf1beb272d2474c90b5b5ec2bca191903db9dbe465fa5141b52053dadf
6
+ metadata.gz: 1ffd490ac6e267a073cf45c54eeb9226dbf9b2ddc0402a00c923f6e25b38cfdd8345805ed429a8aa1e5c09ee7c368869146387e45c7f3da336931d6f38db06ed
7
+ data.tar.gz: 58fafb2c69f7562fe3ea2d09226e6459b0eaac2d3056a8f0590aa69b29a7078c22b6287266b283869b00adebbec790149d62f681a9ed64e26553ca0adbd53132
@@ -1,70 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+
1
4
  module MobileWorkflow
2
5
  module Displayable
3
6
  module Steps
4
7
  module Form
5
- def mw_form_section(label:, identifier:)
8
+ def mw_form_section(label:, id:)
6
9
  raise 'Missing label' if label.nil?
7
- raise 'Missing identifier' if identifier.nil?
8
-
9
- { item_type: :section, label: label, identifier: identifier }
10
+ raise 'Missing id' if id.nil?
11
+
12
+ { item_type: :section, id: id, label: label }
10
13
  end
11
-
12
- def mw_form_multiple_selection(label:, identifier:, multiple_selection_options:, selection_type: :single, optional: false, show_other_option: false)
14
+
15
+ def mw_form_multiple_selection(label:, multiple_selection_options:, id:, selection_type: :single, optional: false, show_other_option: false)
13
16
  raise 'Missing label' if label.nil?
14
- raise 'Missing identifier' if identifier.nil?
17
+ raise 'Missing id' if id.nil?
15
18
  raise 'Missing multiple selection options' if multiple_selection_options.nil?
16
-
17
- { item_type: :multiple_selection, label: label, identifier: identifier, multiple_selection_options: multiple_selection_options, selection_type: selection_type, optional: optional, show_other_option: show_other_option }
19
+
20
+ { item_type: :multiple_selection, id: id, label: label,
21
+ multiple_selection_options: multiple_selection_options, selection_type: selection_type, optional: optional, show_other_option: show_other_option }
18
22
  end
19
-
23
+
20
24
  def mw_form_multiple_selection_options(text:, hint: nil, is_pre_selected: false)
21
25
  raise 'Missing text' if text.nil?
22
-
26
+
23
27
  { text: text, hint: hint, isPreSelected: is_pre_selected }
24
28
  end
25
-
26
- def mw_form_number(label:, identifier:, placeholder: nil, optional: false, symbol_position: :leading, default_text_answer: nil, hint: nil)
29
+
30
+ def mw_form_number(label:, id:, placeholder: nil, optional: false, symbol_position: :leading, default_text_answer: nil, hint: nil)
27
31
  raise 'Missing label' if label.nil?
28
- raise 'Missing identifier' if identifier.nil?
29
-
30
- { item_type: :number, number_type: :number, label: label, identifier: identifier, placeholder: placeholder, optional: optional, symbol_position: symbol_position, default_text_answer: default_text_answer, hint: hint }
32
+ raise 'Missing id' if id.nil?
33
+
34
+ { item_type: :number, number_type: :number, id: id, label: label,
35
+ placeholder: placeholder, optional: optional, symbol_position: symbol_position, default_text_answer: default_text_answer, hint: hint }
31
36
  end
32
-
33
- def mw_form_text(label:, identifier:, placeholder: nil, optional: false, multiline: false, default_text_answer: nil)
37
+
38
+ def mw_form_text(label:, id:, placeholder: nil, optional: false, multiline: false, default_text_answer: nil)
34
39
  raise 'Missing label' if label.nil?
35
- raise 'Missing identifier' if identifier.nil?
36
-
37
- { item_type: :text, label: label, identifier: identifier, placeholder: placeholder, optional: optional, multiline: multiline, default_text_answer: default_text_answer }
40
+ raise 'Missing id' if id.nil?
41
+
42
+ { item_type: :text, id: id, label: label, placeholder: placeholder,
43
+ optional: optional, multiline: multiline, default_text_answer: default_text_answer }
38
44
  end
39
-
40
- def mw_form_date(label:, identifier:, optional: false, default_date_time_answer: nil)
45
+
46
+ def mw_form_date(label:, id:, optional: false, default_text_answer: nil)
41
47
  raise 'Missing label' if label.nil?
42
- raise 'Missing identifier' if identifier.nil?
43
-
44
- { item_type: :date, date_type: :calendar, label: label, identifier: identifier, optional: optional, default_date_time_answer: default_date_time_answer }
48
+ raise 'Missing id' if id.nil?
49
+
50
+ { item_type: :date, date_type: :calendar, id: id, label: label, optional: optional,
51
+ default_text_answer: default_text_answer }
45
52
  end
46
-
47
- def mw_form_time(label:, identifier:, optional: false, default_date_time_answer: nil)
53
+
54
+ def mw_form_time(label:, id:, optional: false, default_text_answer: nil)
48
55
  raise 'Missing label' if label.nil?
49
- raise 'Missing identifier' if identifier.nil?
50
-
51
- { item_type: :time, label: label, identifier: identifier, optional: optional, default_date_time_answer: default_date_time_answer }
56
+ raise 'Missing id' if id.nil?
57
+
58
+ { item_type: :time, id: id, label: label, optional: optional,
59
+ default_text_answer: default_text_answer }
52
60
  end
53
-
54
- def mw_form_email(label:, identifier:, placeholder: nil, optional: false, default_text_answer: nil)
61
+
62
+ def mw_form_email(label:, id:, placeholder: nil, optional: false, default_text_answer: nil)
55
63
  raise 'Missing label' if label.nil?
56
- raise 'Missing identifier' if identifier.nil?
57
-
58
- { item_type: :email, label: label, identifier: identifier, placeholder: placeholder, optional: optional, default_text_answer: default_text_answer }
64
+ raise 'Missing id' if id.nil?
65
+
66
+ { item_type: :email, id: id, label: label, placeholder: placeholder,
67
+ optional: optional, default_text_answer: default_text_answer }
59
68
  end
60
-
61
- def mw_form_password(label:, identifier:, placeholder: nil, optional: false, default_text_answer: nil, hint: nil)
69
+
70
+ def mw_form_password(label:, id:, placeholder: nil, optional: false, default_text_answer: nil, hint: nil)
62
71
  raise 'Missing label' if label.nil?
63
- raise 'Missing identifier' if identifier.nil?
64
-
65
- { item_type: :secure, label: label, identifier: identifier, placeholder: placeholder, optional: optional, default_text_answer: default_text_answer, hint: hint }
72
+ raise 'Missing id' if id.nil?
73
+
74
+ { item_type: :secure, id: id, label: label, placeholder: placeholder,
75
+ optional: optional, default_text_answer: default_text_answer, hint: hint }
66
76
  end
67
77
  end
68
78
  end
69
79
  end
70
- end
80
+ end
@@ -56,7 +56,15 @@ module MobileWorkflow
56
56
  {type: :button, label: label, appleSystemURL: apple_system_url, androidDeepLink: android_deep_link, style: style, sfSymbolName: sf_symbol_name, materialIconName: material_icon_name}.compact
57
57
  end
58
58
  alias_method :mw_display_button_for_system_url, :mw_display_system_url_button
59
-
59
+
60
+ def mw_display_link_button(label:, link_id:, style: :primary, on_success: :none, sf_symbol_name: nil, material_icon_name: nil)
61
+ validate_on_success!(on_success)
62
+ validate_button_style!(style)
63
+
64
+ {type: :button, label: label, linkId: link_id, style: style, onSuccess: on_success, sfSymbolName: sf_symbol_name, materialIconName: material_icon_name}.compact
65
+ end
66
+
67
+ # Remove this method once V1 is no longer being used
60
68
  def mw_display_modal_workflow_button(label:, modal_workflow_name:, style: :primary, on_success: :none, sf_symbol_name: nil, material_icon_name: nil)
61
69
  validate_on_success!(on_success)
62
70
  validate_button_style!(style)
@@ -23,15 +23,16 @@ module MobileWorkflow
23
23
 
24
24
  { id: id.to_s, text: text, detailText: detail_text, type: :listItem, imageURL: preview_url }.compact
25
25
  end
26
-
27
- def mw_stack_button(id:, label:, url: nil, method: :nil, on_success: :none, style: :primary, modal_workflow_name: nil, link_url: nil, sf_symbol_name: nil, apple_system_url: nil, android_deep_link: nil, confirm_title: nil, confirm_text: nil)
26
+
27
+ # Remove `modal_workflow_name` argument once V1 is no longer being used
28
+ def mw_stack_button(id:, label:, url: nil, method: :nil, on_success: :none, style: :primary, modal_workflow_name: nil, link_id: nil, link_url: nil, sf_symbol_name: nil, apple_system_url: nil, android_deep_link: nil, confirm_title: nil, confirm_text: nil, share_text: nil, share_image_url: nil)
28
29
  raise 'Missing id' if id.nil?
29
30
  raise 'Missing label' if label.nil?
30
31
 
31
32
  validate_on_success!(on_success)
32
33
  validate_button_style!(style)
33
34
 
34
- { id: id, type: :button, label: label, url: url, method: method, onSuccess: on_success, style: style, modalWorkflow: modal_workflow_name, linkURL: link_url, sfSymbolName: sf_symbol_name, appleSystemURL: apple_system_url, androidDeepLink: android_deep_link, confirmTitle: confirm_title, confirmText: confirm_text }.compact
35
+ { id: id, type: :button, label: label, url: url, method: method, onSuccess: on_success, style: style, modalWorkflow: modal_workflow_name, linkId: link_id, linkURL: link_url, sfSymbolName: sf_symbol_name, appleSystemURL: apple_system_url, androidDeepLink: android_deep_link, confirmTitle: confirm_title, confirmText: confirm_text, shareText: share_text, shareImageURL: share_image_url }.compact
35
36
  end
36
37
  end
37
38
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Adds a `frozen_string_literal` comment to the top of files created by Rails generators.
4
+ # Taken from https://gist.github.com/thornomad/4e2f0905e2a4a6eefbc4be5772dfd4f7#gistcomment-3533276
5
+ #
6
+ # Warning! Doorkeeper auto generated files already include `frozen_string_literal`, so it will be duplicated.
7
+
8
+ return unless defined?(::Rails::Generators)
9
+
10
+ module RailsGeneratorFrozenStringLiteralPrepend
11
+ RUBY_EXTENSIONS = %w[.rb .rake]
12
+
13
+ def render
14
+ return super unless RUBY_EXTENSIONS.include? File.extname(self.destination)
15
+ "# frozen_string_literal: true\n\n" + super
16
+ end
17
+ end
18
+
19
+ Thor::Actions::CreateFile.prepend RailsGeneratorFrozenStringLiteralPrepend
@@ -67,6 +67,10 @@ module MobileWorkflow
67
67
  end
68
68
  end
69
69
 
70
+ def ability_generator
71
+ copy_file("app/models/ability.rb")
72
+ end
73
+
70
74
  def generate_deserializers
71
75
  say "Generating deserializers"
72
76
 
@@ -99,7 +103,7 @@ module MobileWorkflow
99
103
  route "resources :#{plural_controller_name}, only: [#{actions.map{|a| ":#{a}"}.join(", ")}]"
100
104
  end
101
105
  end
102
-
106
+
103
107
  def generate_seeds
104
108
  template("seeds.rb.erb", "db/seeds.rb", force: true)
105
109
  end
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
5
 
4
6
  ruby '<%= MobileWorkflow::RUBY_VERSION %>'
5
7
 
6
8
  # Core Gems
7
- gem 'rails', '<%= MobileWorkflow::RAILS_VERSION %>'
8
9
  gem 'puma', '~> 5.0'
10
+ gem 'rails', '<%= MobileWorkflow::RAILS_VERSION %>'
9
11
  gem 'sass-rails', '>= 6'
10
12
  gem 'turbolinks', '~> 5'
11
13
 
@@ -14,10 +16,12 @@ gem 'mobile_workflow', '<%= MobileWorkflow::VERSION %>'
14
16
 
15
17
  # Authorisation / Authentication
16
18
  <%- if options[:doorkeeper_oauth] %>
17
- gem 'doorkeeper'
18
19
  gem 'bcrypt'
19
20
  <%- end %>
20
21
  gem 'cancancan', '~> 3.1'
22
+ <%- if options[:doorkeeper_oauth] %>
23
+ gem 'doorkeeper'
24
+ <%- end %>
21
25
 
22
26
  # Admin console
23
27
  gem 'administrate', '~> 0.13.0'
@@ -26,26 +30,39 @@ gem 'administrate-field-enum'
26
30
 
27
31
  <%- if options[:s3_storage] %>
28
32
  # Backend storage for S3
29
- gem "image_processing"
30
33
  gem 'aws-sdk-s3', '~> 1.60', '>= 1.60.1'
31
34
  gem 'aws-sdk-sns', '~> 1.23'
35
+ gem "image_processing"
32
36
  <%- end %>
33
37
 
34
38
  # FFI for Mac M1
35
39
  gem 'ffi', '~> 1.15.1'
36
40
 
41
+ # Error tracking
42
+ gem 'rollbar'
43
+
44
+ # Data migrations
45
+ gem 'data_migrate', '~> 7.0.0'
46
+
37
47
  group :development do
38
- gem 'web-console', '>= 3.3.0'
39
48
  gem 'listen', '>= 3.0.5', '< 3.2'
49
+ gem 'web-console', '>= 3.3.0'
40
50
  end
41
51
 
42
52
  group :development, :test do
43
- gem 'sqlite3'
44
- gem 'rspec-rails', '~> 4.0.0'
45
- gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
53
+ gem 'byebug', platforms: %i[mri mingw x64_mingw]
46
54
  gem 'dotenv-rails'
47
55
  gem 'factory_bot_rails'
56
+ gem 'rspec-rails', '~> 4.0.0'
57
+ gem 'rubocop', '~> 1.16', require: false
58
+ gem 'rubocop-rails', '~> 2.10.0', require: false
59
+ gem 'rubocop-rspec', '~> 2.3.0', require: false
48
60
  gem "rufo"
61
+ gem 'sqlite3'
62
+ end
63
+
64
+ group :test do
65
+ gem 'simplecov', '~> 0.21.2', require: false
49
66
  end
50
67
 
51
68
  group :production do
@@ -10,7 +10,7 @@ class ApiController < ActionController::API
10
10
  def current_resource_owner
11
11
  @current_resource_owner ||= User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token&.accessible?
12
12
  end
13
- alias_method :current_user, :current_resource_owner
13
+ alias current_user current_resource_owner
14
14
 
15
15
  protected
16
16
  def anonymous_action?
@@ -1,9 +1,8 @@
1
1
  module ApplicationHelper
2
-
3
2
  def bootstrap_class_for(flash_type)
4
3
  { success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }.stringify_keys[flash_type.to_s] || flash_type.to_s
5
4
  end
6
-
5
+
7
6
  def flash_messages
8
7
  flash.each do |flash_type, message|
9
8
  concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(flash_type)}", role: 'alert'))
@@ -1,7 +1,7 @@
1
1
  class Ability
2
2
  include CanCan::Ability
3
3
 
4
- def initialize(user)
4
+ def initialize(_user)
5
5
  can :manage, :all
6
6
  end
7
7
  end
@@ -1,6 +1,6 @@
1
1
  class ApplicationRecord < ActiveRecord::Base
2
2
  include MobileWorkflow::Attachable
3
3
  include MobileWorkflow::Displayable
4
-
4
+
5
5
  self.abstract_class = true
6
- end
6
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MobileWorkflow
4
+ class ApplicationJob < ActiveJob::Base
5
+ include Rollbar::ActiveJob
6
+ end
7
+ end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'rails_helper'
4
2
  require 'json'
5
3
 
@@ -1,4 +1,4 @@
1
1
  <%- if options[:doorkeeper_oauth] %>
2
2
  # You can set the OAuth client ID and client secret in your ENV in order to avoid them being reset each time you reset the database.
3
3
  Doorkeeper::Application.create! name: 'Main App', redirect_uri: 'mww://callback', scopes: 'public', uid: ENV['OAUTH_CLIENT_ID'], secret: ENV['OAUTH_CLIENT_SECRET']
4
- <%- end %>
4
+ <%- end %>
@@ -1,10 +1,9 @@
1
1
  class SessionsController < ApplicationController
2
- def new
3
- end
2
+ def new; end
4
3
 
5
4
  def create
6
5
  @user = User.find_by("LOWER(email)= ?", params[:email].downcase)
7
- if @user && @user.authenticate(params[:password])
6
+ if @user&.authenticate(params[:password])
8
7
  session[:user_id] = @user.id
9
8
  redirect_to params[:return_to] || root_url
10
9
  else
@@ -12,4 +11,4 @@ class SessionsController < ApplicationController
12
11
  render :new
13
12
  end
14
13
  end
15
- end
14
+ end
@@ -1,8 +1,8 @@
1
1
  class User < ApplicationRecord
2
2
  has_secure_password
3
3
 
4
- has_many :access_grants, class_name: 'Doorkeeper::AccessGrant', foreign_key: :resource_owner_id, dependent: :destroy
5
- has_many :access_tokens, class_name: 'Doorkeeper::AccessToken', foreign_key: :resource_owner_id, dependent: :destroy
4
+ has_many :access_grants, class_name: 'Doorkeeper::AccessGrant', foreign_key: :resource_owner_id, inverse_of: :resource_owner, dependent: :destroy
5
+ has_many :access_tokens, class_name: 'Doorkeeper::AccessToken', foreign_key: :resource_owner_id, inverse_of: :resource_owner, dependent: :destroy
6
6
 
7
7
  validates :email, presence: true, uniqueness: true
8
8
  end
@@ -4,19 +4,19 @@ class <%= controller_class_name %>Controller < ApiController
4
4
  before_action :rewrite_payload, only: :create
5
5
 
6
6
  load_and_authorize_resource
7
-
7
+
8
8
  <% if index_action? -%>
9
9
  def index
10
10
  render json: @<%= plural_table_name %>.collect(&:list_item_as_json)
11
11
  end
12
-
13
12
  <% end -%>
13
+
14
14
  <% if show_action? -%>
15
15
  def show
16
16
  render json: @<%= singular_table_name %>.display_as_json
17
17
  end
18
-
19
18
  <% end -%>
19
+
20
20
  <% if create_action? -%>
21
21
  def create
22
22
  <% if doorkeeper_oauth? -%>
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'rails_helper'
4
2
  require 'json'
5
3
 
@@ -11,50 +9,60 @@ RSpec.describe <%= controller_class_name %>Controller do
11
9
  let(:token) { instance_double(Doorkeeper::AccessToken, accessible?: true, acceptable?: true, resource_owner_id: user.id) }
12
10
  <% end -%>
13
11
 
14
- <% if index_action? -%>
12
+ <% if index_action? -%>
15
13
  describe 'GET #index' do
16
14
  let!(:<%= controller_class_name.singularize.underscore %>) { create(:<%= controller_class_name.singularize.underscore %>) }
15
+
17
16
  before(:each) do
18
17
  <% if doorkeeper_oauth? -%>
19
18
  allow(subject).to receive(:doorkeeper_token) { token }
20
19
  <% end -%>
21
20
  get :index, params: params
22
21
  end
23
-
22
+
24
23
  context 'ok' do
25
24
  it { expect(json_response[0][:id]).to eq <%= controller_class_name.singularize.underscore %>.id }
26
25
  it { expect(response.status).to eq 200 }
27
26
  end
28
27
  end
29
28
  <% end -%>
29
+
30
30
  <% if show_action? -%>
31
31
  describe 'GET #show' do
32
32
  let(:<%= controller_class_name.singularize.underscore %>) { create(:<%= controller_class_name.singularize.underscore %>) }
33
33
  let(:params) { { id: <%= controller_class_name.singularize.underscore %>.id } }
34
+
34
35
  before(:each) do
35
36
  <% if doorkeeper_oauth? -%>
36
37
  allow(subject).to receive(:doorkeeper_token) { token }
37
38
  <% end -%>
38
39
  get :show, params: params
39
40
  end
40
-
41
- context 'ok' do
41
+
42
+ context 'ok' do
42
43
  it { expect(response.status).to eq 200 }
43
44
  end
44
45
  end
45
-
46
46
  <% end -%>
47
+
47
48
  <% if create_action? -%>
48
49
  describe 'POST #create' do
49
- let(:payload_params) { {text: 'OK'} }
50
+ let(:payload_params) {
51
+ {
52
+ <% attributes_names.each do |attribute| -%>
53
+ <%= attribute %>: 'string',
54
+ <% end -%>
55
+ }
56
+ }
50
57
  let(:params) { { payload: payload_params, binaries: [{identifier: 'record', mimetype: 'video/mp4'}] } }
58
+
51
59
  before(:each) do
52
60
  <% if doorkeeper_oauth? -%>
53
61
  allow(subject).to receive(:doorkeeper_token) { token }
54
62
  <% end -%>
55
63
  post :create, params: params
56
64
  end
57
-
65
+
58
66
  context 'ok' do
59
67
  it { expect(<%= controller_class_name.singularize %>.count).to eq 1 }
60
68
  it { expect(response.status).to eq 201 }
@@ -11,8 +11,8 @@ class <%= class_name %> < <%= parent_class_name.classify %>
11
11
  <% end -%>
12
12
  <% if class_name == 'User' -%>
13
13
  <% if doorkeeper_oauth? -%>
14
- has_many :access_grants, class_name: 'Doorkeeper::AccessGrant', foreign_key: :resource_owner_id, dependent: :destroy
15
- has_many :access_tokens, class_name: 'Doorkeeper::AccessToken', foreign_key: :resource_owner_id, dependent: :destroy
14
+ has_many :access_grants, class_name: 'Doorkeeper::AccessGrant', foreign_key: :resource_owner_id, inverse_of: :resource_owner, dependent: :destroy
15
+ has_many :access_tokens, class_name: 'Doorkeeper::AccessToken', foreign_key: :resource_owner_id, inverse_of: :resource_owner, dependent: :destroy
16
16
  <% end -%>
17
17
  <% attributes.each do |attribute| -%>
18
18
  <% if attribute.name == 'email' -%>
@@ -48,10 +48,6 @@ CODE
48
48
  generate 'administrate:routes'
49
49
  end
50
50
 
51
- def ability_generator
52
- copy_file 'ability.rb', 'app/models/ability.rb'
53
- end
54
-
55
51
  def active_storage
56
52
  rails_command 'active_storage:install'
57
53
  copy_file 'storage.s3.yml', 'config/storage.yml'
@@ -78,6 +74,27 @@ ADMIN_USER=#{admin_user}
78
74
  ADMIN_PASSWORD=#{admin_password}
79
75
  CODE
80
76
  end
77
+
78
+ def rubocop
79
+ copy_file '.rubocop.yml'
80
+ command = 'rubocop --auto-gen-config'
81
+
82
+ puts "Running: #{command}"
83
+ output = `#{command}`
84
+ puts "Output: #{output}"
85
+ end
86
+
87
+ def simplecov
88
+ append_to_file 'spec/rails_helper.rb', "\n# Config for Test Coverage\nrequire 'simplecov'\nSimpleCov.start\nSimpleCov.minimum_coverage 80\n"
89
+ append_to_file '.gitignore', "\n# Ignore test coverage reports\n/coverage\n"
90
+ end
91
+
92
+ def rollbar
93
+ generate 'rollbar'
94
+ gsub_file 'config/initializers/rollbar.rb', 'if Rails.env.test?', 'if Rails.env.test? || Rails.env.development?'
95
+ copy_file 'config/initializers/mobile_workflow_rollbar.rb'
96
+ gsub_file 'app/jobs/application_job.rb', 'class ApplicationJob < ActiveJob::Base', "class ApplicationJob < ActiveJob::Base\n include Rollbar::ActiveJob\n"
97
+ end
81
98
 
82
99
  def git_commit(message = 'Initial commit')
83
100
  git add: "."
@@ -34,13 +34,15 @@ module MobileWorkflow::Cli
34
34
  build :procfiles
35
35
  build :rspec_generator
36
36
  build :factory_bot
37
- build :ability_generator
37
+ build :simplecov
38
+ build :rollbar
38
39
  build :active_storage if options[:s3_storage]
39
40
  build :mobile_workflow_generator, ARGV[1]
40
41
  build :migrate_db
41
42
  build :administrate_generator
42
43
  build :format_source
43
44
  build :generate_dot_env
45
+ build :rubocop
44
46
  build :git_commit
45
47
  build :heroku if options[:heroku]
46
48
  build :dokku, options[:dokku_host] if options[:dokku]
@@ -1,5 +1,5 @@
1
1
  module MobileWorkflow
2
- VERSION = '0.7.7'
2
+ VERSION = '0.9.0'
3
3
  RUBY_VERSION = '2.7.3'
4
4
  RAILS_VERSION = '6.1.3.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobile_workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.7
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-13 00:00:00.000000000 Z
11
+ date: 2022-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -114,7 +114,7 @@ dependencies:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
- description:
117
+ description:
118
118
  email:
119
119
  - matt@futureworkshops.com
120
120
  executables:
@@ -146,6 +146,7 @@ files:
146
146
  - app/models/concerns/mobile_workflow/displayable/steps/styled_content/stack.rb
147
147
  - app/views/layouts/mobile_workflow/application.html.erb
148
148
  - bin/mwf
149
+ - config/initializers/add_frozen_string_literal.rb
149
150
  - config/routes.rb
150
151
  - lib/generators/mobile_workflow/controller_generator.rb
151
152
  - lib/generators/mobile_workflow/install/install_generator.rb
@@ -153,12 +154,13 @@ files:
153
154
  - lib/generators/mobile_workflow/install/templates/Procfile
154
155
  - lib/generators/mobile_workflow/install/templates/Procfile.dev
155
156
  - lib/generators/mobile_workflow/install/templates/README.md.erb
156
- - lib/generators/mobile_workflow/install/templates/ability.rb
157
157
  - lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
158
158
  - lib/generators/mobile_workflow/install/templates/app/helpers/application_helper.rb
159
+ - lib/generators/mobile_workflow/install/templates/app/models/ability.rb
159
160
  - lib/generators/mobile_workflow/install/templates/app/models/application_record.rb
160
161
  - lib/generators/mobile_workflow/install/templates/app/views/layouts/application.html.erb
161
162
  - lib/generators/mobile_workflow/install/templates/app/views/sessions/new.html.erb
163
+ - lib/generators/mobile_workflow/install/templates/config/initializers/mobile_workflow_rollbar.rb
162
164
  - lib/generators/mobile_workflow/install/templates/create_users.rb
163
165
  - lib/generators/mobile_workflow/install/templates/deserializer.rb.erb
164
166
  - lib/generators/mobile_workflow/install/templates/deserializer_spec.rb.erb
@@ -190,7 +192,7 @@ homepage: https://github.com/futureworkshops/mobile_workflow
190
192
  licenses:
191
193
  - MIT
192
194
  metadata: {}
193
- post_install_message:
195
+ post_install_message:
194
196
  rdoc_options: []
195
197
  require_paths:
196
198
  - lib
@@ -205,8 +207,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
207
  - !ruby/object:Gem::Version
206
208
  version: '0'
207
209
  requirements: []
208
- rubygems_version: 3.1.6
209
- signing_key:
210
+ rubygems_version: 3.3.6
211
+ signing_key:
210
212
  specification_version: 4
211
213
  summary: A Rails engine to provide API support for Mobile Workflow Apps.
212
214
  test_files: []