mobile_workflow 0.7.7 → 0.7.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf9a3d0ae2752b171aea1043b7cc57a8425b80ecf086bb226faadffb936fd5ee
4
- data.tar.gz: 1d0c4bf77cbbb66844a58a4d94bfb5532f4706a4a5fa2ae02f01e1e0f72e4939
3
+ metadata.gz: 652ebd5ca3b96f993ee3c6a7bc57863eaa70119fb41aca0586a02430795bd0d1
4
+ data.tar.gz: ab8191098d6eeed1825fd8fd1a2debb5c4ae762cfb887362793e96a7d62278ae
5
5
  SHA512:
6
- metadata.gz: e3c1748bdbe2b84415e434632080968cc02fb4e6e7b5a248bf8d979868b74714ce89c0d04165207d3b67008e45b3f08e4b84f67124a128f971627ad28611591f
7
- data.tar.gz: 90329d6e78a89c601fa6bb5cc62b4d856b9ba264e56d6bfe83b7e1afc5ea5d1849355ccf1beb272d2474c90b5b5ec2bca191903db9dbe465fa5141b52053dadf
6
+ metadata.gz: 4b4acc6286656e349602808ac82b6049da2e8ef3d721fba490346d0f003701c9efdde26fdcf9b2352df2ff3bc34d40bec571f941701129298baa02d8f356ad29
7
+ data.tar.gz: 7a1cfa5d993b5bfc91f98ede6e6c7000990ffd149bafe18c0f4232e80462a7fd9d0cea0eec2c020437e6cdb3dce7a14e747e4b4dfe6e4cd6886b4b28fc0905f3
@@ -37,18 +37,18 @@ module MobileWorkflow
37
37
  { item_type: :text, label: label, identifier: identifier, placeholder: placeholder, optional: optional, multiline: multiline, default_text_answer: default_text_answer }
38
38
  end
39
39
 
40
- def mw_form_date(label:, identifier:, optional: false, default_date_time_answer: nil)
40
+ def mw_form_date(label:, identifier:, optional: false, default_text_answer: nil)
41
41
  raise 'Missing label' if label.nil?
42
42
  raise 'Missing identifier' if identifier.nil?
43
43
 
44
- { item_type: :date, date_type: :calendar, label: label, identifier: identifier, optional: optional, default_date_time_answer: default_date_time_answer }
44
+ { item_type: :date, date_type: :calendar, label: label, identifier: identifier, optional: optional, default_text_answer: default_text_answer }
45
45
  end
46
46
 
47
- def mw_form_time(label:, identifier:, optional: false, default_date_time_answer: nil)
47
+ def mw_form_time(label:, identifier:, optional: false, default_text_answer: nil)
48
48
  raise 'Missing label' if label.nil?
49
49
  raise 'Missing identifier' if identifier.nil?
50
50
 
51
- { item_type: :time, label: label, identifier: identifier, optional: optional, default_date_time_answer: default_date_time_answer }
51
+ { item_type: :time, label: label, identifier: identifier, optional: optional, default_text_answer: default_text_answer }
52
52
  end
53
53
 
54
54
  def mw_form_email(label:, identifier:, placeholder: nil, optional: false, default_text_answer: nil)
@@ -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.7.8'
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.7.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-13 00:00:00.000000000 Z
11
+ date: 2022-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -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
@@ -205,7 +207,7 @@ 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
210
+ rubygems_version: 3.3.5
209
211
  signing_key:
210
212
  specification_version: 4
211
213
  summary: A Rails engine to provide API support for Mobile Workflow Apps.