activeadmin-mongoid 1.0.0 → 2.0.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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codecheck.yml +18 -0
  3. data/.github/workflows/tests.yml +45 -0
  4. data/.gitignore +2 -0
  5. data/.rubocop.yml +104 -0
  6. data/CHANGELOG.md +28 -0
  7. data/Gemfile +11 -8
  8. data/README.md +17 -3
  9. data/activeadmin-mongoid.gemspec +9 -9
  10. data/lib/active_admin/mongoid/association/relatable.rb +7 -1
  11. data/lib/active_admin/mongoid/controllers/resource_controller.rb +9 -10
  12. data/lib/active_admin/mongoid/criteria.rb +0 -1
  13. data/lib/active_admin/mongoid/csv_builder.rb +11 -6
  14. data/lib/active_admin/mongoid/document.rb +4 -16
  15. data/lib/active_admin/mongoid/filter_form_builder.rb +4 -4
  16. data/lib/active_admin/mongoid/filters/resource_extension.rb +4 -2
  17. data/lib/active_admin/mongoid/helpers/collection.rb +3 -1
  18. data/lib/active_admin/mongoid/inputs/filters/select_input.rb +15 -6
  19. data/lib/active_admin/mongoid/resource/attributes.rb +2 -3
  20. data/lib/active_admin/mongoid/resource.rb +1 -1
  21. data/lib/active_admin/mongoid/version.rb +1 -1
  22. data/lib/activeadmin-mongoid.rb +26 -0
  23. data/lib/meta_search/searches/mongoid.rb +4 -4
  24. data/spec/features/smoke_spec.rb +20 -6
  25. data/spec/lib/active_admin/mongoid/filter_form_builder_spec.rb +5 -7
  26. data/spec/lib/active_admin/mongoid/filters/resource_extension_spec.rb +19 -0
  27. data/spec/spec_helper.rb +3 -3
  28. data/spec/support/capybara.rb +0 -2
  29. data/spec/support/debug.rb +2 -2
  30. data/spec/support/mongoid.rb +2 -2
  31. data/tasks/js.rake +0 -2
  32. data/tasks/test.rake +2 -6
  33. data/test_app/Rakefile +1 -1
  34. data/test_app/app/admin/admin_users.rb +0 -1
  35. data/test_app/app/admin/dashboard.rb +4 -5
  36. data/test_app/app/admin/posts.rb +1 -1
  37. data/test_app/app/assets/config/manifest.js +1 -0
  38. data/test_app/app/models/admin_user.rb +11 -11
  39. data/test_app/app/models/post.rb +2 -0
  40. data/test_app/bin/rails +4 -0
  41. data/test_app/bin/rake +4 -0
  42. data/test_app/bin/setup +25 -0
  43. data/test_app/config/application.rb +1 -1
  44. data/test_app/config/boot.rb +4 -5
  45. data/test_app/config/environment.rb +3 -3
  46. data/test_app/config/environments/development.rb +2 -1
  47. data/test_app/config/environments/production.rb +0 -1
  48. data/test_app/config/environments/test.rb +3 -2
  49. data/test_app/config/initializers/active_admin.rb +0 -13
  50. data/test_app/config/initializers/inflections.rb +6 -5
  51. data/test_app/config/initializers/wrap_parameters.rb +0 -1
  52. data/test_app/config/mongoid.7.yml +2 -3
  53. data/test_app/config/mongoid.8.yml +13 -0
  54. data/test_app/config.ru +1 -1
  55. data/test_app/db/migrate/20130514223107_create_admin_notes.rb +3 -3
  56. data/test_app/db/migrate/20130514223108_move_admin_notes_to_comments.rb +2 -2
  57. data/test_app/script/rails +2 -2
  58. data/test_app/test/test_helper.rb +1 -1
  59. metadata +41 -24
  60. data/.travis.yml +0 -12
  61. data/Gemfile.lock +0 -284
  62. data/test_app/config/mongoid.2.yml +0 -20
  63. data/test_app/config/mongoid.3.yml +0 -96
  64. data/test_app/config/mongoid.4.yml +0 -87
  65. data/test_app/config/mongoid.5.yml +0 -7
  66. data/test_app/config/mongoid.6.yml +0 -7
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  require 'spec_helper'
3
2
 
4
3
  describe 'browse the test app' do
@@ -66,7 +65,6 @@ describe 'browse the test app' do
66
65
  end
67
66
 
68
67
  context 'with 1 post' do
69
-
70
68
  before do
71
69
  Post.create!(title: 'Quick Brown Fox', body: 'The quick brown fox jumps over the lazy dog.', view_count: 5, admin_user: admin_user, other_user: other_user)
72
70
 
@@ -182,6 +180,22 @@ describe 'browse the test app' do
182
180
  end
183
181
  end
184
182
 
183
+ describe 'select on a has_and_belongs_to_many association' do
184
+ it 'selects by editor' do
185
+ Post.first.update!(editors: [other_user])
186
+
187
+ select other_email, from: 'Editors'
188
+ click_on 'Filter'
189
+ within '#index_table_posts' do
190
+ expect(page).to have_content('Quick Brown Fox')
191
+ end
192
+
193
+ select email, from: 'Editors'
194
+ click_on 'Filter'
195
+ expect(page).to_not have_content('Quick Brown Fox')
196
+ end
197
+ end
198
+
185
199
  describe 'check_boxes' do
186
200
  it 'checks by other_user' do
187
201
  check email
@@ -232,7 +246,7 @@ describe 'browse the test app' do
232
246
  Post.where(body: 'The quick brown fox jumps over the lazy dog.').update_all(author: { name: 'Bob', city: { name: 'Washington' } })
233
247
  post.author = Author.new name: 'Adam', city: { name: 'California' }
234
248
  post.save!
235
- Post.all.each{|p| p.author.city }
249
+ Post.all.each { |p| p.author.city }
236
250
  end
237
251
 
238
252
  it 'sorts by the embedded document field' do
@@ -275,7 +289,7 @@ describe 'browse the test app' do
275
289
  display_total_text = I18n.t 'active_admin.pagination.multiple',
276
290
  model: 'Posts', total: posts_size,
277
291
  from: offset + 1, to: offset + collection_size
278
- display_total_text = Nokogiri::HTML(display_total_text).text.gsub(' ', ' ')
292
+ display_total_text = Nokogiri::HTML(display_total_text).text.gsub(' ', ' ')
279
293
  pagination_information = page.find('.pagination_information').text
280
294
  expect(pagination_information).to include(display_total_text)
281
295
  end
@@ -313,11 +327,11 @@ describe 'browse the test app' do
313
327
  end
314
328
 
315
329
  it "builds csv" do
330
+ expect(Mongo::QueryCache).to receive(:uncached).and_call_original
316
331
  visit '/admin/admin_users.csv'
317
332
  expect(page.status_code).to eq(200) or eq(304)
333
+ expect(page.body).to include(email, other_email)
318
334
  end
319
-
320
-
321
335
  end
322
336
  end
323
337
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe ActiveAdmin::Filters::FormBuilder do
4
4
  describe '#default_input_type' do
5
- let(:instance) { described_class.new({}, {}, {}, {}) }
5
+ let(:instance) { described_class.new('q', {}, {}, {}) } # object_name must be a String on Rails 6.1+
6
6
  let(:column) { double(:column) }
7
7
  subject { instance.default_input_type(nil) }
8
8
 
@@ -60,11 +60,9 @@ describe ActiveAdmin::Filters::FormBuilder do
60
60
  it { is_expected.to eq :string }
61
61
  end
62
62
 
63
-
64
- # when :date, :datetime, :time; :date_range
65
- # when :string, :text, :object; :string
66
- # when :float, :decimal; :numeric
67
- # when :integer
68
-
63
+ # when :date, :datetime, :time; :date_range
64
+ # when :string, :text, :object; :string
65
+ # when :float, :decimal; :numeric
66
+ # when :integer
69
67
  end
70
68
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActiveAdmin::Filters::ResourceExtension do
4
+ def default_association_filters(klass)
5
+ ActiveAdmin.application.namespace(:admin).resource_for(klass).send(:default_association_filters)
6
+ end
7
+
8
+ it 'includes associations whose key the document stores' do
9
+ expect(default_association_filters(Post)).to include(:admin_user, :other_user, :editors)
10
+ end
11
+
12
+ it 'leaves out has_many associations, whose keys are in the related documents' do
13
+ expect(default_association_filters(AdminUser)).not_to include(:posts)
14
+ end
15
+
16
+ it 'leaves out embedded associations' do
17
+ expect(default_association_filters(Post)).not_to include(:author)
18
+ end
19
+ end
data/spec/spec_helper.rb CHANGED
@@ -11,13 +11,13 @@ if %w(true 1).include?(ENV['COVERAGE'])
11
11
  end
12
12
  end
13
13
 
14
- require File.expand_path("../../test_app/config/environment", __FILE__)
14
+ require File.expand_path('../test_app/config/environment', __dir__)
15
15
  require 'rspec/rails'
16
16
 
17
17
  # Requires supporting ruby files with custom matchers and macros, etc,
18
18
  # in spec/support/ and its subdirectories.
19
- Dir[File.join(File.expand_path("../../", __FILE__), "spec/support/**/*.rb")].each {|f| require f}
20
- Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
19
+ Dir[File.join(File.expand_path('..', __dir__), "spec/support/**/*.rb")].each { |f| require f }
20
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
21
21
 
22
22
  RSpec.configure do |config|
23
23
  # ## Mock Framework
@@ -1,3 +1 @@
1
1
  require 'capybara/rails'
2
- require 'capybara/poltergeist'
3
- Capybara.javascript_driver = :poltergeist
@@ -1,3 +1,3 @@
1
- def debugit( *args, &block )
2
- it( *args, { driver: :poltergeist_debug, inspector: true }, &block )
1
+ def debugit(*args, &block)
2
+ it(*args, { driver: :poltergeist_debug, inspector: true }, &block)
3
3
  end
@@ -1,11 +1,11 @@
1
1
  require 'pathname'
2
2
  require 'mongoid'
3
- root = Pathname(File.expand_path('../../../test_app', __FILE__))
3
+ root = Pathname(File.expand_path('../../test_app', __dir__))
4
4
  version = Mongoid::VERSION.to_i
5
5
 
6
6
  current_config = root.join("config/mongoid.#{version}.yml").read
7
7
  config_file = root.join('config/mongoid.yml')
8
- config_file.open('w') {|c| c << current_config }
8
+ config_file.open('w') { |c| c << current_config }
9
9
 
10
10
  Mongoid.load!(config_file, :test)
11
11
  Mongo::Logger.logger.level = ::Logger::FATAL
data/tasks/js.rake CHANGED
@@ -1,5 +1,4 @@
1
1
  namespace :js do
2
-
3
2
  desc "Compile the JS for Rails apps without Asset Pipeline"
4
3
  task :compile do
5
4
  require 'sprockets'
@@ -28,5 +27,4 @@ namespace :js do
28
27
 
29
28
  FileUtils.mv tmp_base_js, base_js
30
29
  end
31
-
32
30
  end
data/tasks/test.rake CHANGED
@@ -7,10 +7,9 @@ end
7
7
 
8
8
  # Run specs and cukes
9
9
  desc "Run the full suite"
10
- task :test => ['spec:unit', 'spec:integration']
10
+ task test: ['spec:unit', 'spec:integration']
11
11
 
12
12
  namespace :test do
13
-
14
13
  def run_tests_against(*versions)
15
14
  current_version = detect_rails_version if File.exists?("Gemfile.lock")
16
15
 
@@ -33,8 +32,7 @@ namespace :test do
33
32
  end
34
33
 
35
34
  desc "Alias for major_supported_rails"
36
- task :all => :major_supported_rails
37
-
35
+ task all: :major_supported_rails
38
36
  end
39
37
 
40
38
  require 'rspec/core/rake_task'
@@ -42,7 +40,6 @@ require 'rspec/core/rake_task'
42
40
  RSpec::Core::RakeTask.new(:spec)
43
41
 
44
42
  namespace :spec do
45
-
46
43
  desc "Run the unit specs"
47
44
  RSpec::Core::RakeTask.new(:unit) do |t|
48
45
  t.pattern = "spec/unit/**/*_spec.rb"
@@ -52,7 +49,6 @@ namespace :spec do
52
49
  RSpec::Core::RakeTask.new(:integration) do |t|
53
50
  t.pattern = "spec/integration/**/*_spec.rb"
54
51
  end
55
-
56
52
  end
57
53
 
58
54
  #
data/test_app/Rakefile CHANGED
@@ -2,6 +2,6 @@
2
2
  # Add your own tasks in files placed in lib/tasks ending in .rake,
3
3
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
4
 
5
- require File.expand_path('../config/application', __FILE__)
5
+ require File.expand_path('config/application', __dir__)
6
6
 
7
7
  TestApp::Application.load_tasks
@@ -8,7 +8,6 @@ ActiveAdmin.register AdminUser do
8
8
  end
9
9
 
10
10
  filter :email
11
- filter :posts
12
11
 
13
12
  form do |f|
14
13
  f.inputs "Admin Details" do
@@ -1,10 +1,9 @@
1
1
  ActiveAdmin.register_page "Dashboard" do
2
+ menu priority: 1, label: proc { I18n.t("active_admin.dashboard") }
2
3
 
3
- menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") }
4
-
5
- content :title => proc{ I18n.t("active_admin.dashboard") } do
6
- div :class => "blank_slate_container", :id => "dashboard_default_message" do
7
- span :class => "blank_slate" do
4
+ content title: proc { I18n.t("active_admin.dashboard") } do
5
+ div class: "blank_slate_container", id: "dashboard_default_message" do
6
+ span class: "blank_slate" do
8
7
  span I18n.t("active_admin.dashboard_welcome.welcome")
9
8
  small I18n.t("active_admin.dashboard_welcome.call_to_action")
10
9
  end
@@ -9,7 +9,7 @@ ActiveAdmin.register Post do
9
9
  filter :view_count, as: :numeric
10
10
  filter :admin_user, as: :select
11
11
  filter :other_user, as: :check_boxes
12
-
12
+ filter :editors, as: :select
13
13
 
14
14
  index do
15
15
  selectable_column
@@ -0,0 +1 @@
1
+ //= link active_admin.js
@@ -7,25 +7,25 @@ class AdminUser
7
7
  :recoverable, :rememberable, :trackable, :validatable
8
8
 
9
9
  ## Database authenticatable
10
- field :email, :type => String, :default => ""
11
- field :encrypted_password, :type => String, :default => ""
10
+ field :email, type: String, default: ""
11
+ field :encrypted_password, type: String, default: ""
12
12
 
13
13
  ## Recoverable
14
- field :reset_password_token, :type => String
15
- field :reset_password_sent_at, :type => Time
14
+ field :reset_password_token, type: String
15
+ field :reset_password_sent_at, type: Time
16
16
 
17
17
  ## Rememberable
18
- field :remember_created_at, :type => Time
18
+ field :remember_created_at, type: Time
19
19
 
20
20
  ## Trackable
21
- field :sign_in_count, :type => Integer, :default => 0
22
- field :current_sign_in_at, :type => Time
23
- field :last_sign_in_at, :type => Time
24
- field :current_sign_in_ip, :type => String
25
- field :last_sign_in_ip, :type => String
21
+ field :sign_in_count, type: Integer, default: 0
22
+ field :current_sign_in_at, type: Time
23
+ field :last_sign_in_at, type: Time
24
+ field :current_sign_in_ip, type: String
25
+ field :last_sign_in_ip, type: String
26
26
 
27
27
  has_many :posts
28
-
28
+
29
29
  def name
30
30
  email
31
31
  end
@@ -7,7 +7,9 @@ class Post
7
7
  field :view_count, type: ::Integer, default: 0
8
8
  belongs_to :admin_user
9
9
  belongs_to :other_user, class_name: 'AdminUser'
10
+ has_and_belongs_to_many :editors, class_name: 'AdminUser', inverse_of: nil
10
11
 
11
12
  embeds_one :author
12
13
  field :'author.city.name'
14
+
13
15
  end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
data/test_app/bin/rake ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path('..', __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to setup or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at anytime and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ puts "\n== Removing old logs and tempfiles =="
21
+ system! 'bin/rails log:clear tmp:clear'
22
+
23
+ puts "\n== Restarting application server =="
24
+ system! 'bin/rails restart'
25
+ end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ require File.expand_path('boot', __dir__)
2
2
 
3
3
  # Pick the frameworks you want:
4
4
  # require "active_record/railtie"
@@ -1,6 +1,5 @@
1
- require 'rubygems'
1
+ # Rails 6.1 relies on concurrent-ruby to load Logger, which concurrent-ruby 1.3.5 stopped doing.
2
+ require 'logger'
3
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2
4
 
3
- # Set up gems listed in the Gemfile.
4
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
-
6
- require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
+ require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -1,5 +1,5 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
1
+ # Load the Rails application.
2
+ require_relative 'application'
3
3
 
4
- # Initialize the rails application
4
+ # Initialize the Rails application.
5
5
  Rails.application.initialize!
@@ -22,10 +22,11 @@ Rails.application.configure do
22
22
  # Only use best-standards-support built into browsers
23
23
  config.action_dispatch.best_standards_support = :builtin
24
24
 
25
-
26
25
  # Do not compress assets
27
26
  config.assets.compress = false
28
27
 
29
28
  # Expands the lines which load the assets
30
29
  config.assets.debug = true
30
+
31
+ config.eager_load = false
31
32
  end
@@ -60,5 +60,4 @@ Rails.application.configure do
60
60
 
61
61
  # Send deprecation notices to registered listeners
62
62
  config.active_support.deprecation = :notify
63
-
64
63
  end
@@ -24,14 +24,15 @@ Rails.application.configure do
24
24
  config.action_dispatch.show_exceptions = false
25
25
 
26
26
  # Disable request forgery protection in test environment
27
- config.action_controller.allow_forgery_protection = false
27
+ config.action_controller.allow_forgery_protection = false
28
28
 
29
29
  # Tell Action Mailer not to deliver emails to the real world.
30
30
  # The :test delivery method accumulates sent emails in the
31
31
  # ActionMailer::Base.deliveries array.
32
32
  config.action_mailer.delivery_method = :test
33
33
 
34
-
35
34
  # Print deprecation notices to the stderr
36
35
  config.active_support.deprecation = :stderr
36
+
37
+ config.eager_load = false
37
38
  end
@@ -1,6 +1,5 @@
1
1
  Rails.application.config.assets.precompile += ['active_admin.js']
2
2
  ActiveAdmin.setup do |config|
3
-
4
3
  config.load_paths = ["#{Rails.root}/app/admin"]
5
4
 
6
5
  # == Site Title
@@ -60,7 +59,6 @@ ActiveAdmin.setup do |config|
60
59
  # within the controller.
61
60
  config.authentication_method = :authenticate_admin_user!
62
61
 
63
-
64
62
  # == Current User
65
63
  #
66
64
  # Active Admin will associate actions with the current
@@ -70,7 +68,6 @@ ActiveAdmin.setup do |config|
70
68
  # to return the currently logged in user.
71
69
  config.current_user_method = :current_admin_user
72
70
 
73
-
74
71
  # == Logging Out
75
72
  #
76
73
  # Active Admin displays a logout link on each screen. These
@@ -113,14 +110,12 @@ ActiveAdmin.setup do |config|
113
110
  # without_comments.allow_comments = false
114
111
  # end
115
112
 
116
-
117
113
  # == Batch Actions
118
114
  #
119
115
  # Enable and disable Batch Actions
120
116
  #
121
117
  config.batch_actions = true
122
118
 
123
-
124
119
  # == Controller Filters
125
120
  #
126
121
  # You can add before, after and around filters to all of your
@@ -128,7 +123,6 @@ ActiveAdmin.setup do |config|
128
123
  #
129
124
  # config.before_filter :do_something_awesome
130
125
 
131
-
132
126
  # == Register Stylesheets & Javascripts
133
127
  #
134
128
  # We recommend using the built in Active Admin layout and loading
@@ -144,7 +138,6 @@ ActiveAdmin.setup do |config|
144
138
  # To load a javascript file:
145
139
  # config.register_javascript 'my_javascript.js'
146
140
 
147
-
148
141
  # == CSV options
149
142
  #
150
143
  # Set the CSV builder separator (default is ",")
@@ -153,7 +146,6 @@ ActiveAdmin.setup do |config|
153
146
  # Set the CSV builder options (default is {})
154
147
  # config.csv_options = {}
155
148
 
156
-
157
149
  # == Menu System
158
150
  #
159
151
  # You can add a navigation menu to be used in your application, or configure a provided menu
@@ -192,7 +184,6 @@ ActiveAdmin.setup do |config|
192
184
  #
193
185
  # end
194
186
 
195
-
196
187
  # == Pagination
197
188
  #
198
189
  # Pagination is enabled by default for all resources.
@@ -200,7 +191,6 @@ ActiveAdmin.setup do |config|
200
191
  #
201
192
  # config.default_per_page = 30
202
193
 
203
-
204
194
  # == Filters
205
195
  #
206
196
  # By default the index screen includes a “Filters” sidebar on the right
@@ -208,7 +198,4 @@ ActiveAdmin.setup do |config|
208
198
  # You can enable or disable them for all resources here.
209
199
  #
210
200
  # config.filters = true
211
-
212
-
213
201
  end
214
-
@@ -1,15 +1,16 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # Add new inflection rules using the following format
4
- # (all these examples are active by default):
5
- # ActiveSupport::Inflector.inflections do |inflect|
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
6
7
  # inflect.plural /^(ox)$/i, '\1en'
7
8
  # inflect.singular /^(ox)en/i, '\1'
8
9
  # inflect.irregular 'person', 'people'
9
10
  # inflect.uncountable %w( fish sheep )
10
11
  # end
11
- #
12
+
12
13
  # These inflection rules are supported but not enabled by default:
13
- # ActiveSupport::Inflector.inflections do |inflect|
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
14
15
  # inflect.acronym 'RESTful'
15
16
  # end
@@ -7,4 +7,3 @@
7
7
  ActiveSupport.on_load(:action_controller) do
8
8
  wrap_parameters format: [:json]
9
9
  end
10
-
@@ -3,12 +3,11 @@ development:
3
3
  default:
4
4
  database: activeadmin_mongoid_development
5
5
  hosts:
6
- - localhost:27017
6
+ - <%= ENV.fetch('MONGODB_HOST', 'localhost:27017') %>
7
7
 
8
8
  test:
9
9
  clients:
10
10
  default:
11
11
  database: activeadmin_mongoid_test
12
12
  hosts:
13
- - localhost:27017
14
- #scope_overwrite_exception: true
13
+ - <%= ENV.fetch('MONGODB_HOST', 'localhost:27017') %>
@@ -0,0 +1,13 @@
1
+ development:
2
+ clients:
3
+ default:
4
+ database: activeadmin_mongoid_development
5
+ hosts:
6
+ - <%= ENV.fetch('MONGODB_HOST', 'localhost:27017') %>
7
+
8
+ test:
9
+ clients:
10
+ default:
11
+ database: activeadmin_mongoid_test
12
+ hosts:
13
+ - <%= ENV.fetch('MONGODB_HOST', 'localhost:27017') %>
data/test_app/config.ru CHANGED
@@ -1,4 +1,4 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require ::File.expand_path('../config/environment', __FILE__)
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
4
  run TestApp::Application
@@ -1,9 +1,9 @@
1
1
  class CreateAdminNotes < ActiveRecord::Migration
2
2
  def self.up
3
3
  create_table :admin_notes do |t|
4
- t.string :resource_id, :null => false
5
- t.string :resource_type, :null => false
6
- t.references :admin_user, :polymorphic => true
4
+ t.string :resource_id, null: false
5
+ t.string :resource_type, null: false
6
+ t.references :admin_user, polymorphic: true
7
7
  t.text :body
8
8
  t.timestamps
9
9
  end
@@ -15,8 +15,8 @@ class MoveAdminNotesToComments < ActiveRecord::Migration
15
15
  end
16
16
 
17
17
  def self.down
18
- remove_index :active_admin_comments, :column => [:author_type, :author_id]
19
- remove_index :active_admin_comments, :column => [:namespace]
18
+ remove_index :active_admin_comments, column: [:author_type, :author_id]
19
+ remove_index :active_admin_comments, column: [:namespace]
20
20
  remove_column :active_admin_comments, :namespace
21
21
  rename_column :active_admin_comments, :author_id, :admin_user_id
22
22
  rename_column :active_admin_comments, :author_type, :admin_user_type
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
3
 
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
4
+ APP_PATH = File.expand_path('../config/application', __dir__)
5
+ require File.expand_path('../config/boot', __dir__)
6
6
  require 'rails/commands'
@@ -1,5 +1,5 @@
1
1
  ENV["RAILS_ENV"] = "test"
2
- require File.expand_path('../../config/environment', __FILE__)
2
+ require File.expand_path('../config/environment', __dir__)
3
3
  require 'rails/test_help'
4
4
 
5
5
  class ActiveSupport::TestCase