activeadmin-mongoid 0.9.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.
- checksums.yaml +4 -4
- data/.github/workflows/codecheck.yml +18 -0
- data/.github/workflows/tests.yml +45 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +104 -0
- data/CHANGELOG.md +28 -0
- data/Gemfile +11 -8
- data/README.md +21 -6
- data/activeadmin-mongoid.gemspec +10 -10
- data/lib/active_admin/mongoid/association/relatable.rb +20 -0
- data/lib/active_admin/mongoid/controllers/resource_controller.rb +9 -10
- data/lib/active_admin/mongoid/criteria.rb +0 -1
- data/lib/active_admin/mongoid/csv_builder.rb +11 -6
- data/lib/active_admin/mongoid/document.rb +5 -17
- data/lib/active_admin/mongoid/filter_form_builder.rb +5 -5
- data/lib/active_admin/mongoid/filters/resource_extension.rb +5 -3
- data/lib/active_admin/mongoid/helpers/collection.rb +3 -1
- data/lib/active_admin/mongoid/inputs/filters/select_input.rb +15 -6
- data/lib/active_admin/mongoid/resource/attributes.rb +2 -3
- data/lib/active_admin/mongoid/resource.rb +1 -1
- data/lib/active_admin/mongoid/version.rb +1 -1
- data/lib/active_admin/mongoid.rb +1 -0
- data/lib/activeadmin-mongoid.rb +26 -0
- data/lib/meta_search/searches/mongoid.rb +4 -4
- data/spec/features/smoke_spec.rb +20 -7
- data/spec/lib/active_admin/mongoid/filter_form_builder_spec.rb +5 -7
- data/spec/lib/active_admin/mongoid/filters/resource_extension_spec.rb +19 -0
- data/spec/spec_helper.rb +3 -5
- data/spec/support/capybara.rb +0 -2
- data/spec/support/debug.rb +2 -2
- data/spec/support/mongoid.rb +2 -2
- data/tasks/js.rake +0 -2
- data/tasks/test.rake +2 -6
- data/test_app/Rakefile +1 -1
- data/test_app/app/admin/admin_users.rb +0 -1
- data/test_app/app/admin/dashboard.rb +4 -5
- data/test_app/app/admin/posts.rb +1 -1
- data/test_app/app/assets/config/manifest.js +1 -0
- data/test_app/app/models/admin_user.rb +11 -11
- data/test_app/app/models/post.rb +2 -0
- data/test_app/bin/rails +4 -0
- data/test_app/bin/rake +4 -0
- data/test_app/bin/setup +25 -0
- data/test_app/config/application.rb +2 -1
- data/test_app/config/boot.rb +4 -5
- data/test_app/config/environment.rb +3 -3
- data/test_app/config/environments/development.rb +2 -1
- data/test_app/config/environments/production.rb +0 -1
- data/test_app/config/environments/test.rb +3 -2
- data/test_app/config/initializers/active_admin.rb +0 -13
- data/test_app/config/initializers/inflections.rb +6 -5
- data/test_app/config/initializers/wrap_parameters.rb +0 -1
- data/test_app/config/{mongoid.6.yml → mongoid.7.yml} +2 -3
- data/test_app/config/mongoid.8.yml +13 -0
- data/test_app/config.ru +1 -1
- data/test_app/db/migrate/20130514223107_create_admin_notes.rb +3 -3
- data/test_app/db/migrate/20130514223108_move_admin_notes_to_comments.rb +2 -2
- data/test_app/script/rails +2 -2
- data/test_app/test/test_helper.rb +1 -1
- metadata +48 -23
- data/.travis.yml +0 -11
- data/Gemfile.lock +0 -295
- data/test_app/config/mongoid.2.yml +0 -20
- data/test_app/config/mongoid.3.yml +0 -96
- data/test_app/config/mongoid.4.yml +0 -87
- data/test_app/config/mongoid.5.yml +0 -7
|
@@ -10,7 +10,8 @@ module MetaSearch
|
|
|
10
10
|
def initialize relation, params, options
|
|
11
11
|
super(relation)
|
|
12
12
|
@relation = relation
|
|
13
|
-
@params
|
|
13
|
+
@params = params
|
|
14
|
+
@options = options
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
def build
|
|
@@ -78,7 +79,6 @@ module MetaSearch
|
|
|
78
79
|
relation.send(name, *attrs, &block)
|
|
79
80
|
end
|
|
80
81
|
|
|
81
|
-
|
|
82
82
|
def respond_to? name, include_private = false
|
|
83
83
|
name.to_s =~ metasearch_regexp or super
|
|
84
84
|
end
|
|
@@ -92,8 +92,8 @@ module MetaSearch
|
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
def metasearch_regexp
|
|
95
|
-
field_names = klass.fields.map
|
|
96
|
-
conditions = MetaSearch::DEFAULT_WHERES.map {|condition| condition[0...-1]} # pop tail options
|
|
95
|
+
field_names = klass.fields.map { |field| field.second.name }
|
|
96
|
+
conditions = MetaSearch::DEFAULT_WHERES.map { |condition| condition[0...-1] } # pop tail options
|
|
97
97
|
|
|
98
98
|
/\A(#{field_names.join('|')})_(#{conditions.join('|')})\z/
|
|
99
99
|
end
|
data/spec/features/smoke_spec.rb
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
1
|
require 'spec_helper'
|
|
3
|
-
require 'activeadmin'
|
|
4
2
|
|
|
5
3
|
describe 'browse the test app' do
|
|
6
4
|
let(:password) { 'foobar•secret' }
|
|
@@ -67,7 +65,6 @@ describe 'browse the test app' do
|
|
|
67
65
|
end
|
|
68
66
|
|
|
69
67
|
context 'with 1 post' do
|
|
70
|
-
|
|
71
68
|
before do
|
|
72
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)
|
|
73
70
|
|
|
@@ -183,6 +180,22 @@ describe 'browse the test app' do
|
|
|
183
180
|
end
|
|
184
181
|
end
|
|
185
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
|
+
|
|
186
199
|
describe 'check_boxes' do
|
|
187
200
|
it 'checks by other_user' do
|
|
188
201
|
check email
|
|
@@ -233,7 +246,7 @@ describe 'browse the test app' do
|
|
|
233
246
|
Post.where(body: 'The quick brown fox jumps over the lazy dog.').update_all(author: { name: 'Bob', city: { name: 'Washington' } })
|
|
234
247
|
post.author = Author.new name: 'Adam', city: { name: 'California' }
|
|
235
248
|
post.save!
|
|
236
|
-
Post.all.each{|p| p.author.city }
|
|
249
|
+
Post.all.each { |p| p.author.city }
|
|
237
250
|
end
|
|
238
251
|
|
|
239
252
|
it 'sorts by the embedded document field' do
|
|
@@ -276,7 +289,7 @@ describe 'browse the test app' do
|
|
|
276
289
|
display_total_text = I18n.t 'active_admin.pagination.multiple',
|
|
277
290
|
model: 'Posts', total: posts_size,
|
|
278
291
|
from: offset + 1, to: offset + collection_size
|
|
279
|
-
display_total_text
|
|
292
|
+
display_total_text = Nokogiri::HTML(display_total_text).text.gsub(' ', ' ')
|
|
280
293
|
pagination_information = page.find('.pagination_information').text
|
|
281
294
|
expect(pagination_information).to include(display_total_text)
|
|
282
295
|
end
|
|
@@ -314,11 +327,11 @@ describe 'browse the test app' do
|
|
|
314
327
|
end
|
|
315
328
|
|
|
316
329
|
it "builds csv" do
|
|
330
|
+
expect(Mongo::QueryCache).to receive(:uncached).and_call_original
|
|
317
331
|
visit '/admin/admin_users.csv'
|
|
318
332
|
expect(page.status_code).to eq(200) or eq(304)
|
|
333
|
+
expect(page.body).to include(email, other_email)
|
|
319
334
|
end
|
|
320
|
-
|
|
321
|
-
|
|
322
335
|
end
|
|
323
336
|
end
|
|
324
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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,15 +11,13 @@ if %w(true 1).include?(ENV['COVERAGE'])
|
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
require File.expand_path("../../test_app/config/environment", __FILE__)
|
|
14
|
+
require File.expand_path('../test_app/config/environment', __dir__)
|
|
17
15
|
require 'rspec/rails'
|
|
18
16
|
|
|
19
17
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
20
18
|
# in spec/support/ and its subdirectories.
|
|
21
|
-
Dir[File.join(File.expand_path(
|
|
22
|
-
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 }
|
|
23
21
|
|
|
24
22
|
RSpec.configure do |config|
|
|
25
23
|
# ## Mock Framework
|
data/spec/support/capybara.rb
CHANGED
data/spec/support/debug.rb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
def debugit(
|
|
2
|
-
it(
|
|
1
|
+
def debugit(*args, &block)
|
|
2
|
+
it(*args, { driver: :poltergeist_debug, inspector: true }, &block)
|
|
3
3
|
end
|
data/spec/support/mongoid.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
require 'pathname'
|
|
2
2
|
require 'mongoid'
|
|
3
|
-
root = Pathname(File.expand_path('
|
|
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
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 :
|
|
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 :
|
|
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('
|
|
5
|
+
require File.expand_path('config/application', __dir__)
|
|
6
6
|
|
|
7
7
|
TestApp::Application.load_tasks
|
|
@@ -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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
data/test_app/app/admin/posts.rb
CHANGED
|
@@ -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, :
|
|
11
|
-
field :encrypted_password, :
|
|
10
|
+
field :email, type: String, default: ""
|
|
11
|
+
field :encrypted_password, type: String, default: ""
|
|
12
12
|
|
|
13
13
|
## Recoverable
|
|
14
|
-
field :reset_password_token, :
|
|
15
|
-
field :reset_password_sent_at, :
|
|
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, :
|
|
18
|
+
field :remember_created_at, type: Time
|
|
19
19
|
|
|
20
20
|
## Trackable
|
|
21
|
-
field :sign_in_count, :
|
|
22
|
-
field :current_sign_in_at, :
|
|
23
|
-
field :last_sign_in_at, :
|
|
24
|
-
field :current_sign_in_ip, :
|
|
25
|
-
field :last_sign_in_ip, :
|
|
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
|
data/test_app/app/models/post.rb
CHANGED
|
@@ -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
|
data/test_app/bin/rails
ADDED
data/test_app/bin/rake
ADDED
data/test_app/bin/setup
ADDED
|
@@ -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,9 +1,10 @@
|
|
|
1
|
-
require File.expand_path('
|
|
1
|
+
require File.expand_path('boot', __dir__)
|
|
2
2
|
|
|
3
3
|
# Pick the frameworks you want:
|
|
4
4
|
# require "active_record/railtie"
|
|
5
5
|
require "action_controller/railtie"
|
|
6
6
|
require "action_mailer/railtie"
|
|
7
|
+
require "action_view/railtie"
|
|
7
8
|
# require "active_resource/railtie"
|
|
8
9
|
require "sprockets/railtie"
|
|
9
10
|
require "rails/test_unit/railtie"
|
data/test_app/config/boot.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
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.
|
|
@@ -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
|
|
@@ -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
|
|
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
|
-
#
|
|
5
|
-
#
|
|
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
|
|
@@ -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,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, :
|
|
5
|
-
t.string :resource_type, :
|
|
6
|
-
t.references :admin_user, :
|
|
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, :
|
|
19
|
-
remove_index :active_admin_comments, :
|
|
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
|
data/test_app/script/rails
CHANGED
|
@@ -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('
|
|
5
|
-
require File.expand_path('
|
|
4
|
+
APP_PATH = File.expand_path('../config/application', __dir__)
|
|
5
|
+
require File.expand_path('../config/boot', __dir__)
|
|
6
6
|
require 'rails/commands'
|