symphonia 3.2.4 → 3.3.0

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: b8c4882e677df5174631e7c902cdd589ea7c7f8f42a1dbce8fa00b9105e27006
4
- data.tar.gz: 2b9451d2738bf8e8cb55646b8544c4448a9caa8e6ce18d61e9fdae9ecd115bd1
3
+ metadata.gz: 7a195060e6fa12677b383245afdaa0d7cefb75e463031b21aca473c2b2eabc6d
4
+ data.tar.gz: ca98109a38542883af2f24a0eadbfb9363861b09fa98a146437c405ba4872338
5
5
  SHA512:
6
- metadata.gz: 1db4480246a6121eff843b2b158a969c39301319110318373ea2c6cf54ed5a6aae35f984cc34eee52fe6cf90f3f00525c2f75ecb04c7a128b53cf1b3570607f3
7
- data.tar.gz: 2f922eda59ca2e52695805829fc0de5b76cf7b679152e81eac2392c2538eadf40211226df007366b778ea0cc86ce7896215d5e9b084c7599ac1cdc41f60fcca2
6
+ metadata.gz: 4b5a099d7ab9e70cbe8526a9e2a765220c3d137472a08dfcbedebaef43745c96f78dc90512335adf4da26b1e910052231c9fa49fcff11dc8eeda122bb8ef1554
7
+ data.tar.gz: 6f300e80b0373f6f19298f6a1c33a4e059be86e7f1110eeebe74f32e90a04960a3ab2edbadf2d5d54624fbc3b4b38c6734b02abd7f6e857d06c11c6648a49b03
@@ -0,0 +1,88 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+ ### Removed
9
+ - openapi (it seems to be uneccessary)
10
+ - paperclip support
11
+ ### Changed
12
+ - upgrade authlogic to 6.1.0
13
+ ## [3.2.4] - 2020-05-10
14
+ ### Added
15
+ - sidekiq-cron gem
16
+ ## [3.2.3] - 2020-05-07
17
+ ### Fixed
18
+ - find user by token from session
19
+ ## [3.2.2] - 2020-05-05
20
+ ### Changed
21
+ - user/account form layout
22
+ - Sidekiq v6
23
+ ### Fixed
24
+ - UsersController#update Role should be sorted
25
+ ## [3.2.1] - 2020-05-01
26
+ ### Added
27
+ - avatar_url to users
28
+ - uuid to users
29
+ - openapi support
30
+ ### Changed
31
+ - improve setup generator
32
+ - anonymous user have no "enforced" language
33
+ ### Fixed
34
+ - update .rubocop
35
+ - bootstrap_form update to 4.4.0
36
+ - show time in localtime
37
+ ### Removed
38
+ - ckeditor-jquery
39
+ ## [3.1.5] - 2020-01-20
40
+ ### Changed
41
+ - improve split name (Symphonia::UserManagement#name=)
42
+ ## [3.1.4] - 2020-01-17
43
+ ### Changed
44
+ - improve role form
45
+ ## [3.1.3] - 2019-12-21
46
+ ### Added
47
+ - bootstrap_modal_helper extended by `link_to_modal` feature
48
+ ### Changed
49
+ - helper Symphonia::BootstrapModalHelper in BaseController
50
+ - new argument options in `icon` method (pass into `fa_icon`)
51
+ ## [3.1.2] - 2019-12-07
52
+ ### Added
53
+ - skip permission check in link_to_new_entity method
54
+ ### Fixed
55
+ - login form additional buttons
56
+ - lost_password form & mail
57
+ - reset_password form & mail
58
+ ## [3.1.1] - 2019-12-07
59
+ ### Changed
60
+ - accounts registration validation
61
+ - update static 500.html
62
+ ## [3.1.0] - 2019-12-07
63
+ ### Added
64
+ - BaseController for simplier create CRUD inheritance
65
+ - base views (new, form, edit, show and index)
66
+ - general EntityDecorator
67
+ - input field in model Attribute
68
+ - TextAttribute format
69
+ ### Changed
70
+ - registration form refactored
71
+ - update dummy to Rails 6
72
+ ### Removed
73
+ - wicked_pdf dependency
74
+ ## [3.0.3] - 2019-10-06
75
+ ### Changed
76
+ - rubocop.yml
77
+ - use real user in tests instead a dummy object
78
+ ## [3.0.1] - 2019-07-08
79
+ ### Changed
80
+ - do not require password for SSO users
81
+ - hide password field from form of SSO users
82
+ ## [3.0.0] - 2019-07-06
83
+ ### Added
84
+ - external_id on user
85
+ ### Changed
86
+ - users/show only for logged users
87
+ - upgrade to authlogic 5
88
+ - minor improvements
@@ -106,7 +106,6 @@ module Symphonia
106
106
 
107
107
  if params[:password] # && params[:password_confirmation]
108
108
  @user.password = params[:password]
109
- # @user.password_confirmation = params[:password_confirmation]
110
109
  end
111
110
 
112
111
  if @user.changed? && @user.save
@@ -14,87 +14,26 @@ module Symphonia
14
14
  #
15
15
  # before_action :authorize
16
16
  before_action :load_permissions, only: [:new, :edit, :update, :create]
17
- #
18
- # #layout 'admin'
19
- #
20
- # def index
21
- # @query = Symphonia::Role.query.new(self)
22
- # @entities = @query.entities
23
- # respond_to do |format|
24
- # format.html do
25
- # @entities = @entities.page(params[:page])
26
- # render layout: !request.xhr?
27
- # end
28
- # format.xml { render xml: @entities.all }
29
- # format.json { render json: @entities.all }
30
- # end
31
- # end
32
- #
33
- # def show
34
- # @role = Role.find(params[:id])
35
- # respond_to do |format|
36
- # format.html
37
- # format.json { render json: @role }
38
- # end
39
- # end
40
- #
41
- # def new
42
- # @role = Role.new
43
- # end
44
- #
45
- # def edit
46
- # @role = Role.find(params[:id])
47
- # end
48
17
 
49
18
  def create
50
19
  @entity = @role = Role.new(entity_params)
51
20
  @role.permissions = Symphonia::Permissions.find_all(params[:permissions]).map(&:name)
52
21
  super
53
- # respond_to do |format|
54
- # if @role.save
55
- # format.html { redirect_to((params[:continue] ? new_role_path : roles_path), notice: t(:text_created)) }
56
- # format.json { render(json: @role, status: :created, location: @role) }
57
- # else
58
- # format.html { render(action: 'new') }
59
- # format.json { render(json: @role.errors, status: :unprocessable_entity) }
60
- # end
61
- # end
62
22
  end
63
23
 
64
24
  def update
65
25
  @entity = @role = Role.find(params[:id])
66
26
  @role.permissions = Symphonia::Permissions.find_all(params[:permissions]).map(&:name)
67
27
  super
68
- # respond_to do |format|
69
- # if @role.update_attributes(role_params)
70
- # format.html { redirect_to(edit_role_path(@role), notice: t(:text_updated)) }
71
- # format.json { head(:no_content) }
72
- # else
73
- # format.html { render(action: 'edit') }
74
- # format.json { render(json: @role.errors, status: :unprocessable_entity) }
75
- # end
76
- # end
28
+
77
29
  end
78
30
 
79
- # def destroy
80
- # @role = Role.find(params[:id])
81
- # @role.destroy
82
- # respond_to do |format|
83
- # format.html { redirect_to(roles_url, notice: t(:text_destroyed)) }
84
- # format.json { head :no_content }
85
- # format.js { render js: "Symphonia.filters.removeRow('#{view_context.dom_id(@role)}')"}
86
- # end
87
- # end
88
- #
89
31
  private
90
- #
32
+
91
33
  def load_permissions
92
34
  @permissions = Symphonia::Permissions.all
93
35
  end
94
- #
95
- # def role_params
96
- # params.require(:role).permit(:name, :description, permissions: [])
97
- # end
36
+
98
37
  end
99
38
 
100
39
  end
@@ -1,10 +1,5 @@
1
1
  module Symphonia
2
2
  class UsersController < ApplicationController
3
- include Symphonia::Swagger::BaseController
4
- def self.tag_list
5
- %w[User admin]
6
- end
7
- swagger_me entity: "User", base_path: "/admin/users"
8
3
 
9
4
  helper Symphonia::RendererHelper
10
5
 
@@ -38,7 +38,7 @@ module Symphonia
38
38
  end
39
39
  options[:container_class] ||= 'mr-auto'
40
40
 
41
- return content_tag(:ul, s.html_safe, itemscope: '', itemtype: 'http://data-vocabulary.org/BreadcrumbList', class: "navbar-nav #{options[:container_class]}", id: menu.to_s)
41
+ return content_tag(:ul, s.html_safe, itemscope: '', itemtype: 'http://schema.org/BreadcrumbList', class: "navbar-nav #{options[:container_class]}", id: menu.to_s)
42
42
  end
43
43
 
44
44
  def render_menu_node(menu, item, options = {})
@@ -19,6 +19,7 @@ module Symphonia
19
19
  end
20
20
 
21
21
  acts_as_authentic do |config|
22
+ config.crypto_provider = ::Authlogic::CryptoProviders::SCrypt
22
23
  end
23
24
  validates :email, uniqueness: { case_sensitive: false }
24
25
  validates :password,
@@ -30,31 +31,6 @@ module Symphonia
30
31
 
31
32
  include UserManagement
32
33
 
33
- include ::Swagger::Blocks
34
- swagger_component do
35
- schema :User do
36
- key :required, %w[id login email]
37
- property :id do
38
- key :type, "integer"
39
- key :format, "int64"
40
- end
41
- property :fist_name do
42
- key :type, "string"
43
- end
44
- property :last_name do
45
- key :type, "string"
46
- end
47
- property :email do
48
- key :type, "string"
49
- key :format, "email"
50
- end
51
- property :status do
52
- key :type, "string"
53
- key :enum, Symphonia::User.statuses.keys
54
- end
55
- end
56
- end
57
-
58
34
  attr_writer :password_confirmation
59
35
 
60
36
  has_and_belongs_to_many :preferences, foreign_key: 'user_id'
@@ -2,7 +2,6 @@
2
2
  module Symphonia
3
3
  include ::ActiveSupport::Configurable
4
4
 
5
- autoload :Attachable, 'symphonia/attachable'
6
5
  autoload :BaseController, 'symphonia/base_controller'
7
6
  autoload :BootstrapLinkRender, 'symphonia/bootstrap_link_render'
8
7
  autoload :ControllerExtensions, 'symphonia/controller_extensions'
@@ -31,7 +31,6 @@ module Symphonia
31
31
  # @param [Class] model
32
32
  class_attribute :model
33
33
 
34
- include Symphonia::Swagger::BaseController
35
34
  end
36
35
 
37
36
  class_methods do
@@ -6,6 +6,7 @@ require 'symphonia/user_management'
6
6
  require 'rails-i18n'
7
7
  require 'turbolinks'
8
8
  require 'authlogic'
9
+ require 'scrypt'
9
10
  require 'bootstrap'
10
11
 
11
12
  require 'will_paginate'
@@ -15,14 +16,14 @@ require 'jquery-rails'
15
16
  require 'jquery-ui-rails'
16
17
  require 'rdiscount'
17
18
  require 'sortable-table'
18
- require 'paperclip'
19
+ # require 'paperclip'
19
20
  require 'awesome_nested_set'
20
- require 'acts_as_list'
21
+ # require 'acts_as_list'
21
22
  require 'bootstrap_form'
22
23
  require 'the_sortable_tree'
23
24
  require 'bootstrap-datepicker-rails'
24
25
  # require 'wicked_pdf'
25
- require 'swagger/blocks'
26
+ # require 'swagger/blocks'
26
27
 
27
28
  module Symphonia
28
29
 
@@ -31,7 +32,7 @@ module Symphonia
31
32
 
32
33
  config.generators do |g|
33
34
  g.test_framework :rspec, fixture: false
34
- # g.fixture_replacement :factory_girl, dir: 'spec/factories'
35
+ g.fixture_replacement :factory_bot, dir: 'spec/factories'
35
36
  end
36
37
 
37
38
  # Rails 5
@@ -1,3 +1,3 @@
1
1
  module Symphonia
2
- VERSION = '3.2.4'
2
+ VERSION = '3.3.0'
3
3
  end
@@ -6,7 +6,6 @@ FactoryBot.define do
6
6
  login { email }
7
7
  admin { false }
8
8
  password { SecureRandom.hex(16) }
9
- # password_confirmation { password }
10
9
  last_request_at { Time.now }
11
10
 
12
11
  trait :admin do
@@ -28,17 +27,17 @@ FactoryBot.define do
28
27
  sequence(:name) { |n| "#{Faker::Job.title} #{n}" }
29
28
  end
30
29
 
31
- factory :attachment, class: 'Symphonia::Attachment' do
32
- association :attachable, factory: :user
33
- end
34
-
35
- factory :file, parent: :attachment, class: 'Symphonia::CommonFile' do
36
- attachment { File.new(File.expand_path('../../support/common_file.txt', __FILE__)) }
37
- end
38
-
39
- factory :image, parent: :attachment, class: 'Symphonia::Image' do
40
- attachment { File.new(File.expand_path('../../support/symphonia.jpg', __FILE__)) }
41
- end
30
+ # factory :attachment, class: 'Symphonia::Attachment' do
31
+ # association :attachable, factory: :user
32
+ # end
33
+ #
34
+ # factory :file, parent: :attachment, class: 'Symphonia::CommonFile' do
35
+ # attachment { File.new(File.expand_path('../../support/common_file.txt', __FILE__)) }
36
+ # end
37
+ #
38
+ # factory :image, parent: :attachment, class: 'Symphonia::Image' do
39
+ # attachment { File.new(File.expand_path('../../support/symphonia.jpg', __FILE__)) }
40
+ # end
42
41
 
43
42
  factory :preference, class: 'Symphonia::Preference' do
44
43
 
@@ -13,7 +13,7 @@ end
13
13
 
14
14
  # ActiveRecord::Migration.maintain_test_schema!
15
15
 
16
- Paperclip::Attachment.default_options[:path] = "#{Rails.root}/spec/test_files/:class/:id_partition/:style.:extension"
16
+ # Paperclip::Attachment.default_options[:path] = "#{Rails.root}/spec/test_files/:class/:id_partition/:style.:extension"
17
17
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
18
  RSpec.configure do |config|
19
19
  # config.infer_spec_type_from_file_location!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symphonia
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.4
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Pokorny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-10 00:00:00.000000000 Z
11
+ date: 2020-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -72,14 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '5.0'
75
+ version: 6.1.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '5.0'
82
+ version: 6.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: scrypt
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bootstrap
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -98,16 +112,16 @@ dependencies:
98
112
  name: will_paginate
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - ">="
115
+ - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '0'
117
+ version: 3.3.0
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - ">="
122
+ - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: '0'
124
+ version: 3.3.0
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: api-pagination
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -192,48 +206,20 @@ dependencies:
192
206
  - - ">="
193
207
  - !ruby/object:Gem::Version
194
208
  version: 0.1.1
195
- - !ruby/object:Gem::Dependency
196
- name: paperclip
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- type: :runtime
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: awesome_nested_set
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
- - - ">="
214
- - !ruby/object:Gem::Version
215
- version: '0'
216
- type: :runtime
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - ">="
221
- - !ruby/object:Gem::Version
222
- version: '0'
223
- - !ruby/object:Gem::Dependency
224
- name: acts_as_list
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - ">="
213
+ - - "~>"
228
214
  - !ruby/object:Gem::Version
229
- version: '0'
215
+ version: 3.2.1
230
216
  type: :runtime
231
217
  prerelease: false
232
218
  version_requirements: !ruby/object:Gem::Requirement
233
219
  requirements:
234
- - - ">="
220
+ - - "~>"
235
221
  - !ruby/object:Gem::Version
236
- version: '0'
222
+ version: 3.2.1
237
223
  - !ruby/object:Gem::Dependency
238
224
  name: bootstrap_form
239
225
  requirement: !ruby/object:Gem::Requirement
@@ -318,20 +304,6 @@ dependencies:
318
304
  - - "~>"
319
305
  - !ruby/object:Gem::Version
320
306
  version: '0.2'
321
- - !ruby/object:Gem::Dependency
322
- name: swagger-blocks
323
- requirement: !ruby/object:Gem::Requirement
324
- requirements:
325
- - - "~>"
326
- - !ruby/object:Gem::Version
327
- version: '3.0'
328
- type: :runtime
329
- prerelease: false
330
- version_requirements: !ruby/object:Gem::Requirement
331
- requirements:
332
- - - "~>"
333
- - !ruby/object:Gem::Version
334
- version: '3.0'
335
307
  - !ruby/object:Gem::Dependency
336
308
  name: rspec-rails
337
309
  requirement: !ruby/object:Gem::Requirement
@@ -408,14 +380,14 @@ dependencies:
408
380
  requirements:
409
381
  - - "~>"
410
382
  - !ruby/object:Gem::Version
411
- version: '1.3'
383
+ version: 1.4.2
412
384
  type: :runtime
413
385
  prerelease: false
414
386
  version_requirements: !ruby/object:Gem::Requirement
415
387
  requirements:
416
388
  - - "~>"
417
389
  - !ruby/object:Gem::Version
418
- version: '1.3'
390
+ version: 1.4.2
419
391
  - !ruby/object:Gem::Dependency
420
392
  name: sass-rails
421
393
  requirement: !ruby/object:Gem::Requirement
@@ -438,6 +410,7 @@ extensions: []
438
410
  extra_rdoc_files: []
439
411
  files:
440
412
  - ".rubocop.yml"
413
+ - CHANGELOG.md
441
414
  - LICENSE
442
415
  - README.md
443
416
  - Rakefile
@@ -464,14 +437,10 @@ files:
464
437
  - app/assets/stylesheets/symphonia/symphonia_bootstrap.scss
465
438
  - app/channels/application_cable/channel.rb
466
439
  - app/controllers/base_controller.rb
467
- - app/controllers/concerns/symphonia/swagger/base_controller.rb
468
440
  - app/controllers/symphonia/accounts_controller.rb
469
441
  - app/controllers/symphonia/admin_controller.rb
470
- - app/controllers/symphonia/api_controller.rb
471
442
  - app/controllers/symphonia/application_controller.rb
472
- - app/controllers/symphonia/attachments_controller.rb
473
443
  - app/controllers/symphonia/filters_controller.rb
474
- - app/controllers/symphonia/images_controller.rb
475
444
  - app/controllers/symphonia/login_controller.rb
476
445
  - app/controllers/symphonia/roles_controller.rb
477
446
  - app/controllers/symphonia/user_sessions_controller.rb
@@ -484,15 +453,9 @@ files:
484
453
  - app/mailers/symphonia/notifier.rb
485
454
  - app/models/symphonia/admin_module.rb
486
455
  - app/models/symphonia/application_record.rb
487
- - app/models/symphonia/attachment.rb
488
- - app/models/symphonia/common_file.rb
489
456
  - app/models/symphonia/email_preference.rb
490
- - app/models/symphonia/image.rb
491
457
  - app/models/symphonia/preference.rb
492
458
  - app/models/symphonia/role.rb
493
- - app/models/symphonia/swagger/error_model.rb
494
- - app/models/symphonia/swagger/parameters.rb
495
- - app/models/symphonia/swagger/responses.rb
496
459
  - app/models/symphonia/user.rb
497
460
  - app/models/symphonia/user_session.rb
498
461
  - app/views/base/_form.html.erb
@@ -579,7 +542,6 @@ files:
579
542
  - lib/symphonia.rb
580
543
  - lib/symphonia/action_cable/connection.rb
581
544
  - lib/symphonia/admin_constraint.rb
582
- - lib/symphonia/attachable.rb
583
545
  - lib/symphonia/base_controller.rb
584
546
  - lib/symphonia/bootstrap_link_render.rb
585
547
  - lib/symphonia/controller_extensions.rb
@@ -607,10 +569,8 @@ files:
607
569
  - lib/symphonia/version.rb
608
570
  - spec/controllers/account_controller_spec.rb
609
571
  - spec/controllers/admin_controller_spec.rb
610
- - spec/controllers/api_controller_spec.rb
611
572
  - spec/controllers/base_controller_spec.rb
612
573
  - spec/controllers/filters_controller_spec.rb
613
- - spec/controllers/images_controller_spec.rb
614
574
  - spec/controllers/login_controller_spec.rb
615
575
  - spec/controllers/roles_controller_spec.rb
616
576
  - spec/controllers/users_controller_spec.rb
@@ -620,7 +580,6 @@ files:
620
580
  - spec/helpers/symphonia/renderer_helper_spec.rb
621
581
  - spec/mailers/previews/symphonia/notifier_preview.rb
622
582
  - spec/mailers/symphonia/notifier_spec.rb
623
- - spec/models/attachment_spec.rb
624
583
  - spec/models/query/attribute_spec.rb
625
584
  - spec/models/query/filters_spec.rb
626
585
  - spec/models/query/symphonia_query_spec.rb
@@ -628,7 +587,6 @@ files:
628
587
  - spec/models/user_spec.rb
629
588
  - spec/rails_helper.rb
630
589
  - spec/requests/accounts_spec.rb
631
- - spec/requests/attachments_controller_spec.rb
632
590
  - spec/requests/login_spec.rb
633
591
  - spec/requests/roles_spec.rb
634
592
  - spec/requests/users_spec.rb
@@ -671,7 +629,6 @@ test_files:
671
629
  - spec/mailers/symphonia/notifier_spec.rb
672
630
  - spec/mailers/previews/symphonia/notifier_preview.rb
673
631
  - spec/version_spec.rb
674
- - spec/models/attachment_spec.rb
675
632
  - spec/models/query/attribute_spec.rb
676
633
  - spec/models/query/symphonia_query_spec.rb
677
634
  - spec/models/query/filters_spec.rb
@@ -679,7 +636,6 @@ test_files:
679
636
  - spec/models/role_spec.rb
680
637
  - spec/requests/roles_spec.rb
681
638
  - spec/requests/login_spec.rb
682
- - spec/requests/attachments_controller_spec.rb
683
639
  - spec/requests/accounts_spec.rb
684
640
  - spec/requests/users_spec.rb
685
641
  - spec/support/symphonia.jpg
@@ -694,12 +650,10 @@ test_files:
694
650
  - spec/controllers/roles_controller_spec.rb
695
651
  - spec/controllers/login_controller_spec.rb
696
652
  - spec/controllers/users_controller_spec.rb
697
- - spec/controllers/api_controller_spec.rb
698
653
  - spec/controllers/filters_controller_spec.rb
699
654
  - spec/controllers/admin_controller_spec.rb
700
655
  - spec/controllers/account_controller_spec.rb
701
656
  - spec/controllers/base_controller_spec.rb
702
- - spec/controllers/images_controller_spec.rb
703
657
  - spec/views/filters/options.html.erb_spec.rb
704
658
  - spec/rails_helper.rb
705
659
  - spec/helpers/symphonia/application_helper_spec.rb
@@ -1,134 +0,0 @@
1
- module Symphonia
2
- module Swagger
3
- module BaseController
4
- extend ActiveSupport::Concern
5
- # General swagger description
6
- #
7
- # How to use:
8
- # `include Symphonia::Swagger::BaseController`
9
- # # it include all necessary methods then you need call
10
- # `swagger_me entity: "MyModelName", base_path: "/my_entities"`
11
- # for change which tags list are used with all this endpoints override method `tag_list`
12
- #
13
- class_methods do
14
-
15
- # @param [String] name of swagger model
16
- def entity=(name)
17
- @entity = name
18
- end
19
-
20
- # @param [String] path - route
21
- def base_path=(path)
22
- @base_path = path
23
- end
24
-
25
- # @abstract guess entity name from controller
26
- def entity
27
- @entity || name.demodulize.remove("Controller").singularize
28
- end
29
-
30
- # @abstract base route to described controller
31
- def base_path
32
- @base_path || "/#{entity_name.pluralize}"
33
- end
34
-
35
- # @abstract name used in params
36
- def entity_name
37
- entity.underscore
38
- end
39
-
40
- # @return [Array]
41
- def tag_list
42
- [entity]
43
- end
44
-
45
- # @param [String] entity is singular name of described model
46
- # @param [String] base_path in URL where is model located in app
47
- def swagger_me(entity: name.demodulize.remove("Controller").singularize, base_path: nil)
48
- self.entity = entity
49
- self.base_path = base_path || "/#{entity_name.pluralize}"
50
- include GeneralDefinitions
51
- end
52
-
53
- end
54
- module GeneralDefinitions
55
- extend ActiveSupport::Concern
56
- included do
57
- include ::Swagger::Blocks
58
-
59
- base = self
60
- swagger_path "#{base.base_path}.json" do
61
- operation :get do
62
- key :summary, "List"
63
- key :tags, base.tag_list
64
- parameter do
65
- key :name, "q"
66
- key :description, "free-text filter of current entity - `like`"
67
- key :in, "query"
68
- schema type: "string"
69
- end
70
- parameter do
71
- key :name, "set_filter"
72
- key :description, "enable filtering"
73
- key :in, "query"
74
- schema type: "boolean"
75
- end
76
- parameter do
77
- key :name, "sort"
78
- key :description, "name of 'column' for sort. Can be also in format name:asc or :desc"
79
- key :example, "email:desc (for reverse order users by e-mail"
80
- key :in, "query"
81
- schema type: "string"
82
- end
83
- parameter do
84
- key :name, "page"
85
- key :description, "number of requested page"
86
- key :in, "query"
87
- schema type: "integer"
88
- end
89
- extend Symphonia::Swagger::Responses
90
- response 200 do
91
- key :description, "ok"
92
- content "application/json" do
93
- schema type: "array" do
94
- items do
95
- key "$ref", base.entity
96
- end
97
- end
98
- end
99
- end
100
- end
101
- end
102
-
103
- swagger_path "#{base.base_path}/{id}.json" do
104
- operation :get do
105
- key :summary, 'Find by ID'
106
- key :description, 'Returns a single entity'
107
- key :tags, base.tag_list
108
- parameter do
109
- key :name, "id"
110
- key :in, "path"
111
- key :description, 'ID to fetch'
112
- key :required, true
113
- schema do
114
- key :type, "integer"
115
- key :format, "int64"
116
- end
117
- end
118
- extend Symphonia::Swagger::Responses
119
- response 200 do
120
- key :description, 'detail object response'
121
- content "application/json" do
122
- schema do
123
- key :'$ref', base.entity
124
- end
125
- end
126
- end
127
- end
128
- end
129
- end
130
- end
131
-
132
- end
133
- end
134
- end
@@ -1,78 +0,0 @@
1
- module Symphonia
2
- class ApiController < ApplicationController
3
- include ::Swagger::Blocks
4
- # https://github.com/fotinakis/swagger-blocks
5
- swagger_component do
6
- security_scheme "token" do
7
- key :type, "apiKey"
8
- key :name, "key"
9
- key :in, "header"
10
- end
11
- end
12
-
13
- swagger_root openapi: "3.0.0" do
14
- info do
15
- key :version, '2.0.0'
16
- key :title, "API"
17
- key :description, ""
18
- contact do
19
- key :name, 'Lukas Pokorny'
20
- key :email, 'pokorny@luk4s.cz'
21
- end
22
- license do
23
- key :name, 'GPLv3'
24
- end
25
- end
26
-
27
- security do
28
- key :token, []
29
- end
30
-
31
- tag name: "admin" do
32
- key :description, "endpoints required `admin`"
33
- end
34
- tag name: "User" do
35
- end
36
- end
37
-
38
- # A list of all classes that have swagger_* declarations.
39
- SWAGGERED_CLASSES = [
40
- UsersController,
41
- User,
42
- Swagger::ErrorModel,
43
- ]
44
- def self.for_documentation
45
- SWAGGERED_CLASSES + Symphonia::ApiController::SWAGGERED_CLASSES
46
- end
47
-
48
- # @param [String] name of tag
49
- # @param [String] description
50
- def self.add_tag(name:, description:)
51
- swagger_root_node.tag name: name, description: description
52
- end
53
-
54
- # @return [Swagger::Blocks::Nodes::RootNode]
55
- def self.swagger_root_node
56
- node = Symphonia::ApiController.send(:_swagger_nodes)
57
- node[:root_node]
58
- end
59
-
60
- # @param [String] text
61
- def self.api_title=(text)
62
- swagger_root_node.data[:info].data[:title] = text
63
- end
64
-
65
- # @param [String] text
66
- def self.api_description=(text)
67
- swagger_root_node.data[:info].data[:description] = text
68
- end
69
-
70
- def index
71
- json = ::Swagger::Blocks.build_root_json(self.class.for_documentation + [self.class])
72
- respond_to do |format|
73
- format.yaml { render plain: json.deep_stringify_keys.to_yaml }
74
- format.json { render json: json }
75
- end
76
- end
77
- end
78
- end
@@ -1,37 +0,0 @@
1
- module Symphonia
2
- class AttachmentsController < ApplicationController
3
-
4
- before_action :require_login, :find_attachment
5
-
6
- def show
7
- # find_attachment
8
- render(plain: @attachment.attachment.url(:original), layout: false)
9
- end
10
-
11
- def destroy
12
- # find_attachment
13
- @attachment.destroy
14
- respond_to do |format|
15
- format.html do
16
- flash[:notice] = t(:"text_#{@attachment.type.underscore}_successfully_destroy")
17
- redirect_back_or_default(polymorphic_path(@attachment.attachable))
18
- end
19
- format.js
20
- end
21
- end
22
-
23
- def reorder
24
- # find_attachment
25
- new_position = params.require(:position).to_i
26
- @attachment.insert_at(new_position)
27
- head :ok
28
- end
29
-
30
- private
31
-
32
- def find_attachment
33
- @attachment = Attachment.find(params.require(:id))
34
- end
35
- end
36
-
37
- end
@@ -1,16 +0,0 @@
1
- module Symphonia
2
- class ImagesController < ApplicationController
3
- # before_action :require_login
4
-
5
- # raise '??? images ??'
6
- # def index
7
- # @images = Image.order(created_at: :asc)
8
- # @images = @images.like(params[:q]) if params[:q].present?
9
- # @images = @images.page(params[:page])
10
- # respond_to do |format|
11
- # format.html
12
- # format.js
13
- # end
14
- # end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- require 'acts_as_list'
2
- module Symphonia
3
- class Attachment < ApplicationRecord
4
- self.table_name = 'attachments'
5
-
6
- belongs_to :attachable, polymorphic: true, touch: true, optional: true
7
- acts_as_list scope: :attachable
8
-
9
- scope :like, proc {|q| where(arel_table[:description].matches("%#{q}%"))}
10
-
11
- def name
12
- attachment_file_name
13
- end
14
- end
15
-
16
- end
@@ -1,9 +0,0 @@
1
- module Symphonia
2
- class CommonFile < Attachment
3
- class_attribute :paperclip_options
4
- has_attached_file :attachment
5
-
6
- validates_attachment :attachment, presence: true, size: {in: 0..2.megabytes}
7
- do_not_validate_attachment_file_type :attachment
8
- end
9
- end
@@ -1,46 +0,0 @@
1
- module Symphonia
2
- class Image < Attachment
3
-
4
- class_attribute :paperclip_options
5
-
6
- def self.image_styles
7
- Symphonia.config[:paperclip_styles] || {
8
- tiny_thumb: '120x120>', thumb: '200x200>', medium: '400x300>', large: '800x600>', original: '1280x800>'
9
- }
10
- end
11
-
12
- has_attached_file(:attachment, {
13
- styles: image_styles,
14
- url: :paperclip_attachment_url,
15
- convert_options: {
16
- thumb: '-strip -quality 75',
17
- tiny_thumb: '-strip -quality 75',
18
- large: '-strip -quality 90'
19
- }
20
- })
21
-
22
- before_post_process :transliterate_file_name
23
-
24
- validates_attachment :attachment, presence: true, content_type: {
25
- content_type: %w(image/jpeg image/jpg image/JPG image/png image/gif)}, size: {in: 0..5.megabytes}
26
-
27
-
28
- def url(variant = :original)
29
- attachment.url(variant)
30
- end
31
-
32
- private
33
-
34
- def paperclip_attachment_url
35
- paperclip_options.try(:[], :url) || Paperclip::Attachment.default_options[:url]
36
- end
37
-
38
- def transliterate_file_name
39
- extension = File.extname(attachment_file_name).remove('.')
40
- filename = File.basename(attachment_file_name, '.*')
41
- self.attachment.instance_write(:file_name, "#{filename.parameterize}.#{extension}")
42
- end
43
-
44
- end
45
-
46
- end
@@ -1,24 +0,0 @@
1
- module Symphonia
2
- module Swagger
3
- class ErrorModel
4
- include ::Swagger::Blocks
5
-
6
- swagger_component do
7
- schema :ErrorModel do
8
- key :required, %w[attribute messages]
9
- property :attribute do
10
- key :type, "string"
11
- key :example, "login"
12
- end
13
- property :messages do
14
- key :type, "array"
15
- items do
16
- key :type, "string"
17
- key :example, "cannot be blank"
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,21 +0,0 @@
1
- module Symphonia
2
- module Swagger
3
- module Parameters
4
- def self.extended(base)
5
-
6
- base.parameter do
7
- key :name, "format"
8
- key :description, "specify format of response"
9
- key :in, "path"
10
- key :required, true
11
- schema do
12
- key :type, "string"
13
- key :enum, %w[json]
14
- end
15
- end
16
-
17
- end
18
- end
19
-
20
- end
21
- end
@@ -1,27 +0,0 @@
1
- module Symphonia
2
- module Swagger
3
- module Responses
4
- def self.extended(base)
5
- base.response 401 do
6
- key :description, 'not authorized'
7
- end
8
- base.response 404 do
9
- key :description, 'not found'
10
- end
11
- base.response 406 do
12
- key :description, 'not allowed'
13
- end
14
- base.response 422 do
15
- key :description, 'unprocessable entity'
16
- content "application/json" do
17
- schema "$ref": "ErrorModel"
18
- end
19
- end
20
- base.response 500 do
21
- key :description, 'internal server error'
22
- end
23
- end
24
- end
25
-
26
- end
27
- end
@@ -1,35 +0,0 @@
1
- module Symphonia
2
- module Attachable
3
-
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- has_many :images, -> { order(:position) }, as: :attachable, dependent: :destroy, validate: false, class_name: 'Symphonia::Image'
8
- has_many :common_files, -> { order(:position) }, as: :attachable, dependent: :destroy, class_name: 'Symphonia::CommonFile'
9
-
10
- # validate do |container|
11
- # container.images.each do |img|
12
- # next if img.valid?
13
- # img.errors.full_messages.each do |msg|
14
- # errors.add(:base, "#{img.name}: #{msg}")
15
- # end
16
- # end
17
- # end
18
-
19
- def image_attachments=(form_images=[])
20
- form_images.each do |attribute|
21
- self.images.build(attachment: attribute)
22
- end
23
- end
24
-
25
- def file_attachments=(form_files=[])
26
- form_files.each do |attribute|
27
- self.common_files.build(attachment: attribute)
28
- end
29
- end
30
-
31
- end
32
-
33
- end
34
-
35
- end
@@ -1,9 +0,0 @@
1
- module Symphonia
2
- RSpec.describe ApiController do
3
- routes { Symphonia::Engine.routes }
4
-
5
- it "#index" do
6
- get :index, params: {format: "yml"}
7
- end
8
- end
9
- end
@@ -1,5 +0,0 @@
1
- module Symphonia
2
- RSpec.describe ImagesController do
3
-
4
- end
5
- end
@@ -1,22 +0,0 @@
1
- describe Symphonia::Attachment do
2
-
3
- context 'files' do
4
- let(:file) { FactoryBot.create(:file) }
5
- it '#create' do
6
- expect { file }.to change(described_class, :count).by 1
7
- end
8
-
9
- it 'just create common file' do
10
- f = nil
11
- expect { f = FactoryBot.create(:file, attachable: nil) }.to change(described_class, :count).by 1
12
- expect(f.attachable).to be_nil
13
- end
14
- end
15
-
16
- context 'images' do
17
- let(:image) { FactoryBot.create(:image) }
18
- it '#create', pending: "When `identify` missing" do
19
- expect { image }.to change(described_class, :count).by 1
20
- end
21
- end
22
- end
@@ -1,23 +0,0 @@
1
- describe Symphonia::AttachmentsController, logged: true do
2
-
3
- let!(:file) { FactoryBot.create(:file) }
4
- let(:images) { FactoryBot.create_list(:image, 3, attachable_id: nil, attachable_type: nil) }
5
-
6
- it '#show' do
7
- get symphonia.attachment_path(file)
8
- expect(response.body).to match file.attachment.url(:original)
9
- end
10
-
11
- it '#destroy' do
12
- expect{ delete(symphonia.attachment_path(file)) }.to change(Symphonia::Attachment, :count).by -1
13
- end
14
-
15
- it '#reorder', pending: "When `identify` missing" do
16
- expect { images }.to change(Symphonia::Image, :count).by 3
17
- patch symphonia.reorder_attachment_path images.last, 1
18
- expect(response).to have_http_status :success
19
- imgs = Symphonia::Image.order(:position).to_a
20
- expect(imgs.first.id).to be > imgs.last.id
21
- end
22
-
23
- end