mobile_workflow 0.5.7 → 0.5.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: 843610afaa8207693d3f1be346698ca58e4022a3575b6953ef52c343781c649c
4
- data.tar.gz: b787b24ab9fbf0f47910a889f23a59094d214db55c6eb0950609b674ba01ed64
3
+ metadata.gz: 713ccaaf463cd2815599e145de07b2b2cc5f838242f49e8e97a9eafebb691d10
4
+ data.tar.gz: f95cdbe9e1474adc2813c2c14edc113bd56b13bbb0661de16b2abe27368d1c30
5
5
  SHA512:
6
- metadata.gz: 427d7c382ebc60cdf5ebd79f4257d2ec268cd0f52d7c7bd583afc1774c3adecaef910b163e06d1a754fa2340dfd352f23ae3c06056d97762e7b6fe878713b7cc
7
- data.tar.gz: e98d3ebb68a12e42b3911d63fe16e4fe578ece0fc8e86814ac401d80a171fcd854d7a42f1a522fc535fc06d56eed1bb902e2a597b3d9d73a4c3c2b4603ce59a7
6
+ metadata.gz: 936c2c40cf080691b9c867214d09dea90dd4a16f2370e6f2b7b0d307a965e78863dfb3a761839f8fc46463727e96a7d0e7f37e4767aade6132b202715faa6917
7
+ data.tar.gz: 126597e1a681f59d770b40c8c2c830398932b2d69c8b8d81c5e3a5fbd52e9e3f858d15e857b10ecede4c1caf2600090406cf2d0ea2212122c0fd705e19a6e7dd
@@ -8,13 +8,18 @@ module MobileWorkflow
8
8
 
9
9
  class_option :attributes, type: :array, default: [], banner: "field:type field:type"
10
10
  class_option :actions, type: :array, default: [], banner: "index create update destroy"
11
+ class_option :doorkeeper_oauth, type: :boolean, default: false
11
12
 
12
13
  def copy_controller_and_spec_files
13
14
  template "controller.rb.erb", File.join("app/controllers", controller_class_path, "#{controller_file_name}_controller.rb")
14
15
  template "controller_spec.rb.erb", File.join("spec/controllers", controller_class_path, "#{controller_file_name}_controller_spec.rb")
15
16
  end
16
17
 
17
- private
18
+ private
19
+ def doorkeeper_oauth?
20
+ options[:doorkeeper_oauth]
21
+ end
22
+
18
23
  def attributes_names
19
24
  options[:attributes].map{ |attribute| attribute.split(":").first }
20
25
  end
@@ -32,6 +32,11 @@ module MobileWorkflow
32
32
  template("user.rb.erb", "app/models/user.rb")
33
33
  template("sessions_controller.rb.erb", "app/controllers/sessions_controller.rb")
34
34
  route "resources :sessions, only: [:new, :create]"
35
+
36
+ # View related for login screen
37
+ copy_file("views/layout/application.html.erb")
38
+ copy_file("views/sessions/new.html.erb")
39
+ copy_file("helpers/application_helper.rb")
35
40
  end
36
41
 
37
42
  def generate_models
@@ -12,12 +12,12 @@ gem 'turbolinks', '~> 5'
12
12
  # Mobile Workflow
13
13
  #gem 'mobile_workflow', path: '../mobile_workflow'
14
14
  #gem 'mobile_workflow', github: 'FutureWorkshops/mobile_workflow'
15
- gem 'mobile_workflow', '0.5.5'
15
+ gem 'mobile_workflow'
16
16
 
17
17
  # Authorisation / Authentication
18
18
  <%- if options[:doorkeeper_oauth] %>
19
19
  gem 'doorkeeper'
20
- gem 'bcrypt-ruby'
20
+ gem 'bcrypt'
21
21
  <%- end %>
22
22
  gem 'cancancan', '~> 3.1'
23
23
 
@@ -8,7 +8,7 @@ class ApiController < ActionController::API
8
8
  before_action :doorkeeper_authorize!, unless: :anonymous_action?
9
9
 
10
10
  def current_resource_owner
11
- User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token&.accessible?
11
+ @current_resource_owner ||= User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token&.accessible?
12
12
  end
13
13
  alias_method :current_user, :current_resource_owner
14
14
 
@@ -0,0 +1,13 @@
1
+ module ApplicationHelper
2
+
3
+ def bootstrap_class_for(flash_type)
4
+ { success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }.stringify_keys[flash_type.to_s] || flash_type.to_s
5
+ end
6
+
7
+ def flash_messages
8
+ flash.each do |flash_type, message|
9
+ concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(flash_type)}", role: 'alert'))
10
+ end
11
+ nil
12
+ end
13
+ end
@@ -3,7 +3,7 @@ class SessionsController < ApplicationController
3
3
  end
4
4
 
5
5
  def create
6
- @user = User.find_by(email: params[:email])
6
+ @user = User.find_by("LOWER(email)= ?", params[:email].downcase)
7
7
  if @user && @user.authenticate(params[:password])
8
8
  session[:user_id] = @user.id
9
9
  redirect_to params[:return_to] || root_url, notice: "Logged in!"
@@ -1,4 +1,4 @@
1
1
  class User < ApplicationRecord
2
2
  has_secure_password
3
- validates :email, presence: true
3
+ validates :email, presence: true, uniqueness: true
4
4
  end
@@ -0,0 +1,18 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <!-- Required meta tags -->
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7
+
8
+ <!-- Bootstrap CSS -->
9
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
10
+
11
+ <title>MW Project</title>
12
+ </head>
13
+ <body>
14
+ <div class="container">
15
+ <%= yield %>
16
+ </div>
17
+ </body>
18
+ </html>
@@ -0,0 +1,20 @@
1
+ <h1>Sign In</h1>
2
+
3
+ <%= flash_messages %>
4
+
5
+ <%= form_tag sessions_path, method: :post do %>
6
+ <%= hidden_field_tag :return_to, params[:return_to] %>
7
+
8
+ <div class="form-group">
9
+ <%= label_tag :email %>
10
+ <%= email_field_tag :email, nil, class: "form-control" %>
11
+ </div>
12
+
13
+ <div class="form-group">
14
+ <%= label_tag :password %>
15
+ <%= password_field_tag :password, nil, class: "form-control" %>
16
+ </div>
17
+
18
+ <%= submit_tag 'Sign In', class: "btn btn-primary" %>
19
+ <% end %>
20
+
@@ -6,10 +6,19 @@ require 'json'
6
6
  RSpec.describe <%= controller_class_name %>Controller do
7
7
  let(:params) { {} }
8
8
  let(:json_response) { JSON.parse(response.body, symbolize_names: true) }
9
+ <% if doorkeeper_oauth? -%>
10
+ let(:user) { create(:user) }
11
+ let(:token) { instance_double('Doorkeeper::AccessToken', :accessible? => true, :acceptable? => true, resource_owner_id: user.id) }
12
+ <% end -%>
9
13
 
10
14
  describe 'GET #index' do
11
15
  let!(:<%= controller_class_name.singularize.underscore %>) { create(:<%= controller_class_name.singularize.underscore %>) }
12
- before(:each) { get :index, params: params }
16
+ before(:each) do
17
+ <% if doorkeeper_oauth? -%>
18
+ allow(subject).to receive(:doorkeeper_token) { token }
19
+ <% end -%>
20
+ get :index, params: params
21
+ end
13
22
 
14
23
  context 'ok' do
15
24
  it { expect(json_response[0][:id]).to eq <%= controller_class_name.singularize.underscore %>.id }
@@ -20,7 +29,12 @@ RSpec.describe <%= controller_class_name %>Controller do
20
29
  describe 'GET #show' do
21
30
  let(:<%= controller_class_name.singularize.underscore %>) { create(:<%= controller_class_name.singularize.underscore %>) }
22
31
  let(:params) { { id: <%= controller_class_name.singularize.underscore %>.id } }
23
- before(:each) { get :show, params: params }
32
+ before(:each) do
33
+ <% if doorkeeper_oauth? -%>
34
+ allow(subject).to receive(:doorkeeper_token) { token }
35
+ <% end -%>
36
+ get :show, params: params
37
+ end
24
38
 
25
39
  context 'ok' do
26
40
  it { expect(response.status).to eq 200 }
@@ -30,7 +44,12 @@ RSpec.describe <%= controller_class_name %>Controller do
30
44
  describe 'POST #create' do
31
45
  let(:payload_params) { {text: 'OK'} }
32
46
  let(:params) { { payload: payload_params, binaries: [{identifier: 'record', mimetype: 'video/mp4'}] } }
33
- before(:each) { post :create, params: params }
47
+ before(:each) do
48
+ <% if doorkeeper_oauth? -%>
49
+ allow(subject).to receive(:doorkeeper_token) { token }
50
+ <% end -%>
51
+ post :create, params: params
52
+ end
34
53
 
35
54
  context 'ok' do
36
55
  it { expect(<%= controller_class_name.singularize %>.count).to eq 1 }
@@ -1,5 +1,5 @@
1
1
  module MobileWorkflow
2
- VERSION = '0.5.7'
2
+ VERSION = '0.5.8'
3
3
  RUBY_VERSION = '2.5.5'
4
4
  RAILS_VERSION = '6.1.0'
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.5.7
4
+ version: 0.5.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-01-02 00:00:00.000000000 Z
11
+ date: 2021-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -112,10 +112,13 @@ files:
112
112
  - lib/generators/mobile_workflow/install/templates/README.md.erb
113
113
  - lib/generators/mobile_workflow/install/templates/ability.rb
114
114
  - lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
115
+ - lib/generators/mobile_workflow/install/templates/helpers/application_helper.rb
115
116
  - lib/generators/mobile_workflow/install/templates/seeds.rb.erb
116
117
  - lib/generators/mobile_workflow/install/templates/sessions_controller.rb.erb
117
118
  - lib/generators/mobile_workflow/install/templates/storage.s3.yml
118
119
  - lib/generators/mobile_workflow/install/templates/user.rb.erb
120
+ - lib/generators/mobile_workflow/install/templates/views/layouts/application.html.erb
121
+ - lib/generators/mobile_workflow/install/templates/views/sessions/new.html.erb
119
122
  - lib/generators/mobile_workflow/templates/controller.rb.erb
120
123
  - lib/generators/mobile_workflow/templates/controller_spec.rb.erb
121
124
  - lib/mobile_workflow.rb
@@ -148,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
151
  - !ruby/object:Gem::Version
149
152
  version: '0'
150
153
  requirements: []
151
- rubygems_version: 3.1.4
154
+ rubygems_version: 3.0.8
152
155
  signing_key:
153
156
  specification_version: 4
154
157
  summary: A Rails engine to provide API support for Mobile Workflow Apps.