symphonia 2.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +674 -0
  3. data/README.md +16 -0
  4. data/Rakefile +44 -0
  5. data/app/assets/images/bg-checker.png +0 -0
  6. data/app/assets/images/bullet.gif +0 -0
  7. data/app/assets/images/close.png +0 -0
  8. data/app/assets/images/loading.gif +0 -0
  9. data/app/assets/images/next.png +0 -0
  10. data/app/assets/images/prev.png +0 -0
  11. data/app/assets/javascripts/ckeditor/plugins/autogrow/plugin.js +232 -0
  12. data/app/assets/javascripts/ckeditor/plugins/autogrow/samples/autogrow.html +102 -0
  13. data/app/assets/javascripts/ckeditor/plugins/image_chooser/icons/addimage.png +0 -0
  14. data/app/assets/javascripts/ckeditor/plugins/image_chooser/plugin.js +15 -0
  15. data/app/assets/javascripts/symphonia/Sortable.js +1249 -0
  16. data/app/assets/javascripts/symphonia/_core.js +45 -0
  17. data/app/assets/javascripts/symphonia/application.js.erb +147 -0
  18. data/app/assets/javascripts/symphonia/filters.js +44 -0
  19. data/app/assets/javascripts/symphonia/symphonia_bootstrap_dialog.js +136 -0
  20. data/app/assets/javascripts/symphonia/symphonia_ckeditor.js +55 -0
  21. data/app/assets/stylesheets/symphonia/application.css +4 -0
  22. data/app/assets/stylesheets/symphonia/basic.scss +218 -0
  23. data/app/assets/stylesheets/symphonia/filters.scss +19 -0
  24. data/app/assets/stylesheets/symphonia/symphonia_bootstrap.scss +56 -0
  25. data/app/channels/application_cable/channel.rb +5 -0
  26. data/app/controllers/symphonia/accounts_controller.rb +169 -0
  27. data/app/controllers/symphonia/admin_controller.rb +22 -0
  28. data/app/controllers/symphonia/api_controller.rb +64 -0
  29. data/app/controllers/symphonia/application_controller.rb +8 -0
  30. data/app/controllers/symphonia/attachments_controller.rb +37 -0
  31. data/app/controllers/symphonia/filters_controller.rb +23 -0
  32. data/app/controllers/symphonia/images_controller.rb +16 -0
  33. data/app/controllers/symphonia/login_controller.rb +80 -0
  34. data/app/controllers/symphonia/roles_controller.rb +100 -0
  35. data/app/controllers/symphonia/user_sessions_controller.rb +16 -0
  36. data/app/controllers/symphonia/users_controller.rb +168 -0
  37. data/app/helpers/symphonia/application_helper.rb +422 -0
  38. data/app/helpers/symphonia/bootstrap_modal_helper.rb +59 -0
  39. data/app/helpers/symphonia/form_helper.rb +50 -0
  40. data/app/helpers/symphonia/renderer_helper.rb +85 -0
  41. data/app/mailers/symphonia/application_mailer.rb +6 -0
  42. data/app/mailers/symphonia/notifier.rb +42 -0
  43. data/app/models/symphonia/admin_module.rb +18 -0
  44. data/app/models/symphonia/application_record.rb +14 -0
  45. data/app/models/symphonia/attachment.rb +16 -0
  46. data/app/models/symphonia/common_file.rb +9 -0
  47. data/app/models/symphonia/email_preference.rb +5 -0
  48. data/app/models/symphonia/image.rb +46 -0
  49. data/app/models/symphonia/preference.rb +12 -0
  50. data/app/models/symphonia/role.rb +55 -0
  51. data/app/models/symphonia/swagger/error_model.rb +19 -0
  52. data/app/models/symphonia/swagger/responses.rb +27 -0
  53. data/app/models/symphonia/user.rb +141 -0
  54. data/app/models/symphonia/user_session.rb +19 -0
  55. data/app/views/common/403.html.erb +5 -0
  56. data/app/views/common/404.html.erb +2 -0
  57. data/app/views/layouts/symphonia/_modal.html.erb +19 -0
  58. data/app/views/layouts/symphonia/_query.html.erb +51 -0
  59. data/app/views/layouts/symphonia/application.html.erb +45 -0
  60. data/app/views/layouts/symphonia/application.pdf.erb +15 -0
  61. data/app/views/layouts/symphonia/mailer.html.erb +13 -0
  62. data/app/views/symphonia/accounts/_detail.html.erb +65 -0
  63. data/app/views/symphonia/accounts/_form.html.erb +14 -0
  64. data/app/views/symphonia/accounts/edit.html.erb +9 -0
  65. data/app/views/symphonia/accounts/edit.js.erb +5 -0
  66. data/app/views/symphonia/accounts/lost_password.html.erb +6 -0
  67. data/app/views/symphonia/accounts/lost_password.js.erb +3 -0
  68. data/app/views/symphonia/accounts/new_activation.html.erb +11 -0
  69. data/app/views/symphonia/accounts/new_activation.js.erb +6 -0
  70. data/app/views/symphonia/accounts/register.html.erb +20 -0
  71. data/app/views/symphonia/accounts/reset_password.html.erb +18 -0
  72. data/app/views/symphonia/accounts/update.js.erb +1 -0
  73. data/app/views/symphonia/admin/index.html.erb +15 -0
  74. data/app/views/symphonia/attachments/destroy.js.erb +1 -0
  75. data/app/views/symphonia/common/_editable_images_grid.html.erb +12 -0
  76. data/app/views/symphonia/common/_filters.html.erb +23 -0
  77. data/app/views/symphonia/common/_locale_chooser.html.erb +16 -0
  78. data/app/views/symphonia/common/_share_links.html.erb +5 -0
  79. data/app/views/symphonia/filters/options.html.erb +36 -0
  80. data/app/views/symphonia/filters/options.js.erb +9 -0
  81. data/app/views/symphonia/filters/table.html.erb +21 -0
  82. data/app/views/symphonia/login/_form.html.erb +19 -0
  83. data/app/views/symphonia/login/new.html.erb +11 -0
  84. data/app/views/symphonia/login_sessions/new.html.erb +1 -0
  85. data/app/views/symphonia/notifier/activation_user.html.erb +7 -0
  86. data/app/views/symphonia/notifier/activation_user.text.erb +3 -0
  87. data/app/views/symphonia/notifier/reset_password_user.html.erb +7 -0
  88. data/app/views/symphonia/notifier/reset_password_user.text.erb +3 -0
  89. data/app/views/symphonia/notifier/test_mail.html.erb +2 -0
  90. data/app/views/symphonia/notifier/test_mail.text.erb +3 -0
  91. data/app/views/symphonia/notifier/user_change_to_active.html.erb +3 -0
  92. data/app/views/symphonia/notifier/user_change_to_active.text.erb +1 -0
  93. data/app/views/symphonia/notifier/user_registered.html.erb +13 -0
  94. data/app/views/symphonia/notifier/user_registered.text.erb +8 -0
  95. data/app/views/symphonia/roles/_form.html.erb +30 -0
  96. data/app/views/symphonia/roles/edit.html.erb +5 -0
  97. data/app/views/symphonia/roles/index.html.erb +6 -0
  98. data/app/views/symphonia/roles/new.html.erb +4 -0
  99. data/app/views/symphonia/roles/show.html.erb +5 -0
  100. data/app/views/symphonia/users/_form.html.erb +13 -0
  101. data/app/views/symphonia/users/edit.html.erb +26 -0
  102. data/app/views/symphonia/users/edit.js.erb +3 -0
  103. data/app/views/symphonia/users/edit_current.html.erb +7 -0
  104. data/app/views/symphonia/users/index.html.erb +5 -0
  105. data/app/views/symphonia/users/new.html.erb +8 -0
  106. data/app/views/symphonia/users/show.html.erb +63 -0
  107. data/config/locales/cs.yml +233 -0
  108. data/config/locales/en.yml +47 -0
  109. data/config/routes.rb +52 -0
  110. data/db/migrate/20130714140500_create_users.rb +49 -0
  111. data/db/migrate/20130714140501_create_roles.rb +16 -0
  112. data/db/migrate/20130714140502_create_preferences.rb +26 -0
  113. data/db/migrate/20130828175114_create_attachments.rb +20 -0
  114. data/db/migrate/20141213204351_create_admin_modules.rb +20 -0
  115. data/db/seeds.rb +12 -0
  116. data/lib/generators/symphonia/entity_controller/entity_controller_generator.rb +48 -0
  117. data/lib/generators/symphonia/entity_controller/templates/controller.rb +100 -0
  118. data/lib/generators/symphonia/query/query_generator.rb +37 -0
  119. data/lib/generators/symphonia/setup/setup_generator.rb +52 -0
  120. data/lib/generators/symphonia/setup/templates/404.html +26 -0
  121. data/lib/generators/symphonia/setup/templates/500.html +37 -0
  122. data/lib/generators/symphonia/setup/templates/Gemfile +18 -0
  123. data/lib/generators/symphonia/setup/templates/base_layout.html.erb +46 -0
  124. data/lib/generators/symphonia/setup/templates/design.scss +4 -0
  125. data/lib/generators/symphonia/setup/templates/settings.rb +65 -0
  126. data/lib/generators/symphonia/setup/templates/spec_helper.rb +18 -0
  127. data/lib/symphonia/action_cable/connection.rb +31 -0
  128. data/lib/symphonia/admin_constraint.rb +9 -0
  129. data/lib/symphonia/attachable.rb +35 -0
  130. data/lib/symphonia/base_controller.rb +96 -0
  131. data/lib/symphonia/bootstrap_link_render.rb +69 -0
  132. data/lib/symphonia/controller_extensions.rb +200 -0
  133. data/lib/symphonia/engine.rb +137 -0
  134. data/lib/symphonia/form_builder.rb +137 -0
  135. data/lib/symphonia/menu_manager.rb +23 -0
  136. data/lib/symphonia/model_attributes/attribute.rb +137 -0
  137. data/lib/symphonia/model_attributes.rb +102 -0
  138. data/lib/symphonia/model_filters/base.rb +82 -0
  139. data/lib/symphonia/model_filters/boolean_filter.rb +26 -0
  140. data/lib/symphonia/model_filters/date_filter.rb +81 -0
  141. data/lib/symphonia/model_filters/integer_filter.rb +18 -0
  142. data/lib/symphonia/model_filters/select_filter.rb +48 -0
  143. data/lib/symphonia/model_filters/string_filter.rb +18 -0
  144. data/lib/symphonia/model_filters.rb +10 -0
  145. data/lib/symphonia/object.rb +31 -0
  146. data/lib/symphonia/permissions.rb +93 -0
  147. data/lib/symphonia/query.rb +275 -0
  148. data/lib/symphonia/query_columns/attribute_column.rb +43 -0
  149. data/lib/symphonia/query_columns/generic_column.rb +165 -0
  150. data/lib/symphonia/query_columns.rb +8 -0
  151. data/lib/symphonia/spec_helper.rb +4 -0
  152. data/lib/symphonia/user_management.rb +58 -0
  153. data/lib/symphonia/version.rb +4 -0
  154. data/lib/symphonia.rb +20 -0
  155. data/spec/controllers/account_controller_spec.rb +90 -0
  156. data/spec/controllers/admin_controller_spec.rb +35 -0
  157. data/spec/controllers/api_controller_spec.rb +9 -0
  158. data/spec/controllers/filters_controller_spec.rb +35 -0
  159. data/spec/controllers/images_controller_spec.rb +5 -0
  160. data/spec/controllers/login_controller_spec.rb +20 -0
  161. data/spec/controllers/roles_controller_spec.rb +12 -0
  162. data/spec/controllers/users_controller_spec.rb +47 -0
  163. data/spec/factories/factories.rb +52 -0
  164. data/spec/helpers/symphonia/application_helper_spec.rb +62 -0
  165. data/spec/mailers/previews/symphonia/notifier_preview.rb +27 -0
  166. data/spec/mailers/symphonia/notifier_spec.rb +76 -0
  167. data/spec/models/attachment_spec.rb +22 -0
  168. data/spec/models/query/attribute_spec.rb +8 -0
  169. data/spec/models/query/symphonia_query_spec.rb +70 -0
  170. data/spec/models/role_spec.rb +13 -0
  171. data/spec/models/user_spec.rb +10 -0
  172. data/spec/rails_helper.rb +13 -0
  173. data/spec/requests/accounts_spec.rb +118 -0
  174. data/spec/requests/attachments_controller_spec.rb +23 -0
  175. data/spec/requests/login_spec.rb +26 -0
  176. data/spec/requests/roles_spec.rb +10 -0
  177. data/spec/requests/users_spec.rb +50 -0
  178. data/spec/spec_helper.rb +101 -0
  179. data/spec/support/common_file.txt +2 -0
  180. data/spec/support/query.rb +36 -0
  181. data/spec/support/shared.rb +62 -0
  182. data/spec/support/shared_controllers.rb +31 -0
  183. data/spec/support/stub_users.rb +32 -0
  184. data/spec/support/symphonia.jpg +0 -0
  185. data/spec/support/wait_for_ajax.rb +15 -0
  186. data/spec/version_spec.rb +5 -0
  187. data/spec/views/filters/options.html.erb_spec.rb +14 -0
  188. metadata +697 -0
@@ -0,0 +1,50 @@
1
+ # require_relative '../spec_helper.rb'
2
+ module Symphonia
3
+ describe User, logged: :admin do
4
+ let(:admin_user) { FactoryBot.create(:user, :admin) }
5
+ subject { 'user' }
6
+
7
+ let(:route) { symphonia }
8
+ include_examples 'a requests', :mail
9
+
10
+ let(:current_user) { described_class.send(:current) }
11
+ context 'permissions', logged: true do
12
+ let(:regular_user) { FactoryBot.create(:user) }
13
+ let(:user) { FactoryBot.create(subject) }
14
+
15
+ it '#account' do
16
+ expect(current_user.admin?).to eq false
17
+ get symphonia.account_path
18
+ expect(response).to have_http_status :success
19
+ end
20
+
21
+ it '#show' do
22
+ expect(current_user.admin?).to eq false
23
+ get symphonia.polymorphic_path(current_user)
24
+ expect(response).to have_http_status :success
25
+ end
26
+
27
+ it '#show without permissions' do
28
+ expect(current_user.admin?).to eq false
29
+ expect(current_user.id).not_to eq user.id
30
+ get symphonia.polymorphic_path user
31
+ expect(response).to have_http_status :forbidden
32
+ end
33
+
34
+ context '#update' do
35
+ it 'own profile' do
36
+ put symphonia.polymorphic_path(Symphonia::User.current, params: { subject => { email: Faker::Internet.unique.email } })
37
+ expect(response).to redirect_to Symphonia::User.current
38
+ end
39
+
40
+ it 'another use' do
41
+ put symphonia.polymorphic_path(user, params: { subject => { password: '1234' } })
42
+ expect(response).to have_http_status :forbidden
43
+ end
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+
@@ -0,0 +1,101 @@
1
+ require 'rspec/rails'
2
+ require 'pry-rails'
3
+ require 'faker'
4
+ require 'factory_bot_rails'
5
+ require 'database_cleaner'
6
+ require 'sass-rails'
7
+ require 'authlogic/test_case'
8
+
9
+
10
+ Dir.glob(File.expand_path('../support/*.rb', __FILE__)).each do |file|
11
+ require file
12
+ end
13
+
14
+ ActiveRecord::Migration.maintain_test_schema!
15
+
16
+ Paperclip::Attachment.default_options[:path] = "#{Rails.root}/spec/test_files/:class/:id_partition/:style.:extension"
17
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
+ RSpec.configure do |config|
19
+ # config.infer_spec_type_from_file_location!
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ config.include FactoryBot::Syntax::Methods
44
+ config.include Authlogic::TestCase
45
+
46
+ config.before(:suite) do
47
+ DatabaseCleaner.strategy = :transaction
48
+ DatabaseCleaner.clean_with(:truncation, except: %w(ar_internal_metadata))
49
+ end
50
+
51
+ config.before(:each) do
52
+ DatabaseCleaner.strategy = :transaction
53
+ Rails.application.config.action_mailer.delivery_method = :test
54
+ end
55
+
56
+ config.before(:each, type: :feature) do
57
+ # :rack_test driver's Rack app under test shares database connection
58
+ # with the specs, so continue to use transaction strategy for speed.
59
+ unless Capybara.current_driver == :rack_test
60
+ # Driver is probably for an external browser with an app
61
+ # under test that does *not* share a database connection with the
62
+ # specs, so use truncation strategy.
63
+ DatabaseCleaner.strategy = :truncation
64
+ end
65
+ end
66
+
67
+ config.before(:each) do
68
+ ActiveJob::Base.queue_adapter = :test
69
+ DatabaseCleaner.start
70
+ end
71
+
72
+ config.after(:suite) do
73
+ FileUtils.rm_rf(Dir["#{Rails.root}/spec/test_files/"])
74
+ end
75
+
76
+ config.append_after(:each) do
77
+ DatabaseCleaner.clean
78
+ end
79
+
80
+ config.use_transactional_fixtures = false
81
+
82
+ config.infer_spec_type_from_file_location!
83
+
84
+ config.filter_rails_from_backtrace!
85
+
86
+ config.before(:each) do |ex|
87
+ meta = ex.metadata
88
+ unless meta[:null]
89
+ case meta[:logged]
90
+ when :admin
91
+ allow(controller).to receive(:current_user).and_return(admin_user) if meta[:type] == :controller
92
+ allow(Symphonia::User).to receive(:current).and_return(admin_user)
93
+ when true, 'true'
94
+ user = regular_user
95
+ allow(controller).to receive(:current_user).and_return(user) if meta[:type] == :controller
96
+ allow(Symphonia::User).to receive(:current).and_return(user)
97
+ end
98
+ end
99
+ end
100
+
101
+ end
@@ -0,0 +1,2 @@
1
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris dolor felis, sagittis at, luctus sed, aliquam non, tellus. Etiam dictum tincidunt diam. Suspendisse sagittis ultrices augue. Nullam justo enim, consectetuer nec, ullamcorper ac, vestibulum in, elit. Nulla quis diam. Duis bibendum, lectus ut viverra rhoncus, dolor nunc faucibus libero, eget facilisis enim ipsum id lacus. Sed convallis magna eu sem. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nulla accumsan, elit sit amet varius semper, nulla mauris mollis quam, tempor suscipit diam nulla vel leo. Nullam eget nisl. Pellentesque pretium lectus id turpis. Proin in tellus sit amet nibh dignissim sagittis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam commodo dui eget wisi. Nunc auctor. Vivamus porttitor turpis ac leo. Nullam sapien sem, ornare ac, nonummy non, lobortis a enim. In sem justo, commodo ut, suscipit at, pharetra vitae, orci.
2
+
@@ -0,0 +1,36 @@
1
+ class DummyQueryEntity
2
+
3
+ include ActiveModel::AttributeMethods
4
+
5
+ attr_accessor :name, :status, :author
6
+
7
+ include Symphonia::ModelAttributes
8
+
9
+ # enum
10
+ def self.statuses
11
+ { "active" => 1, "pending" => 5, "archived" => 9 }
12
+ end
13
+
14
+ def self.table_name
15
+ "dummy"
16
+ end
17
+
18
+ def self.arel_table
19
+ Arel::Table.new("dummy")
20
+ end
21
+
22
+ def self.columns_hash
23
+ { status: :integer, author_id: :integer }
24
+ end
25
+
26
+ register_query do
27
+ add_attribute :name, :link, sort: %i[first_name last_name], default: true, filter: "string"
28
+ add_attribute :status, :enum, default: true, filter: "select"
29
+ add_attribute :author, sort: false, default: true
30
+ end
31
+
32
+ def self.human_attribute_name(*args)
33
+ args.first
34
+ end
35
+
36
+ end
@@ -0,0 +1,62 @@
1
+ RSpec.shared_examples 'a requests' do |attribute|
2
+ let(:entity) { FactoryBot.create(subject) }
3
+ let(:entities_list) { FactoryBot.create_list(subject, 3) }
4
+
5
+ it '#index' do
6
+ entities_list
7
+ get route.polymorphic_path(subject.pluralize)
8
+ expect(response).to have_http_status(:success)
9
+ end
10
+
11
+ it '#new' do
12
+ get route.new_polymorphic_path subject
13
+ expect(response).to have_http_status(:success)
14
+ end
15
+
16
+ it '#edit' do
17
+ get route.edit_polymorphic_path(entity)
18
+ expect(response).to have_http_status(:success)
19
+ end
20
+
21
+ it '#show' do
22
+ get route.polymorphic_path(entity)
23
+ expect(response).to have_http_status(:success)
24
+ end
25
+
26
+ context '#create' do
27
+
28
+ it 'invalid' do
29
+ expect {
30
+ post route.polymorphic_path(subject.pluralize, { subject => { attribute => '' } })
31
+ }.to change(described_class, :count).by 0
32
+ expect(response).to have_http_status :success
33
+ end
34
+
35
+ it 'valid' do
36
+ expect {
37
+ post(route.polymorphic_path(subject.pluralize, { subject => FactoryBot.attributes_for(subject) }))
38
+ }.to change(described_class, :count).by 1
39
+ expect(response).to have_http_status :redirect
40
+ end
41
+
42
+ end
43
+
44
+ context '#update' do
45
+
46
+ it 'invalid' do
47
+ put route.polymorphic_path(entity, { subject => { attribute => '' } })
48
+ expect(response).to have_http_status :success
49
+ expect(entity.reload.send(attribute)).not_to be_blank
50
+ end
51
+
52
+ it 'valid' do
53
+ new_value = Faker::Internet.unique.email
54
+ put route.polymorphic_path(entity, { subject => { attribute => new_value } })
55
+ expect(entity.reload.send(attribute)).to eq new_value
56
+ expect(response).to have_http_status :redirect
57
+ end
58
+
59
+
60
+ end
61
+
62
+ end
@@ -0,0 +1,31 @@
1
+ RSpec.shared_examples 'a controller actions' do |factory|
2
+ let(:entity) { FactoryBot.create(factory) }
3
+ let(:entities_list) { FactoryBot.create_list(factory, 3) }
4
+
5
+ it '#index' do
6
+ entities_list
7
+ get :index, params: { use_route: 'admin' }
8
+ expect(response).to have_http_status(:success)
9
+ end
10
+
11
+ it '#destroy' do
12
+ entity # touch
13
+ expect { delete :destroy, params: { id: entity } }.to change(subject, :count).by(-1)
14
+ end
15
+
16
+ context 'json' do
17
+
18
+ it '#index' do
19
+ entities_list
20
+ get :index, params: { use_route: 'admin', format: 'json' }
21
+ expect(response).to have_http_status(:success)
22
+ end
23
+
24
+ it '#show' do
25
+ get :show, params: {id: entity, format: 'json'}
26
+ expect(response).to have_http_status(:success)
27
+ expect(response.body).to include %Q{"id":#{entity.id}}
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,32 @@
1
+ def admin_user
2
+ @admin ||= instance_double(Symphonia::User,
3
+ id: 1,
4
+ admin: true,
5
+ admin?: true,
6
+ authorize?: true,
7
+ logged_in?: true,
8
+ allowed_to?: true,
9
+ persistence_token: SecureRandom.hex(12)
10
+ )
11
+ end
12
+
13
+ def regular_user
14
+ # @user ||= instance_double(Symphonia::User,
15
+ # id: 2,
16
+ # admin: false,
17
+ # admin?: false,
18
+ # authorize?: false,
19
+ # logged_in?: true,
20
+ # allowed_to?: false,
21
+ # persistence_token: SecureRandom.hex(12)
22
+ # )
23
+ @user ||= FactoryBot.build_stubbed :user
24
+ end
25
+
26
+ def add_permission *args
27
+ @role ||= FactoryBot.build_stubbed :role
28
+ @role.permissions = args
29
+ regular_user.role = @role
30
+ # allow(regular_user).to receive(:role).and_return @role
31
+ @role
32
+ end
Binary file
@@ -0,0 +1,15 @@
1
+ module WaitForAjax
2
+ def wait_for_ajax
3
+ Timeout.timeout(Capybara.default_max_wait_time) do
4
+ loop until finished_all_ajax_requests?
5
+ end
6
+ end
7
+
8
+ def finished_all_ajax_requests?
9
+ page.evaluate_script('jQuery.active').zero?
10
+ end
11
+ end
12
+
13
+ RSpec.configure do |config|
14
+ config.include WaitForAjax, type: :feature
15
+ end
@@ -0,0 +1,5 @@
1
+ RSpec.describe Symphonia do
2
+ it "version" do
3
+ expect(Symphonia::VERSION).to match /\d+\./
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ RSpec.describe "symphonia/filters/options.html.erb" do
2
+ helper Symphonia::ApplicationHelper
3
+ let(:query) do
4
+ q = Symphonia::Query.new
5
+ q.model = DummyQueryEntity
6
+ q
7
+ end
8
+ it "render" do
9
+ assign(:query, query)
10
+ params[:path] = "/"
11
+ render
12
+ expect(rendered).to include "form", "checked"
13
+ end
14
+ end