Permalink
Browse files

instead of rescuing exceptions, we avoid problems with migrations tha…

…t haven't been run yet by being more stringent with our late-binding. The goal is to be able to load the rails environment even if the database has no tables in it.
  • Loading branch information...
1 parent efd6b38 commit fa06e5705a7e57070fe69ff8e1c8afe1f1d47ade Francis Hwang committed Feb 21, 2012
Showing with 48 additions and 20 deletions.
  1. +15 −6 Rakefile
  2. +18 −9 lib/admin_assistant.rb
  3. +11 −1 lib/admin_assistant/builder.rb
  4. +2 −2 rails_3_0/Gemfile.lock
  5. +2 −2 rails_3_1/Gemfile.lock
View
@@ -25,19 +25,28 @@ end
desc 'Run all tests across all supported Rails gem versions.'
task :test do
+ ENV['CMD'] = 'rake'
+ Rake::Task[:run_everywhere].invoke
+end
+
+desc 'Run CMD in all tested rails environments.'
+task :run_everywhere do
+ core_cmd = ENV['CMD']
+ cmds = []
base = Dir.pwd
version_dirs = %w(rails_3_0 rails_3_1)
version_dirs.each do |dir|
path = File.join(base, dir)
- cmd = "cd #{path} && bundle exec rake"
- puts cmd
- puts `#{cmd}`
+ cmds << "cd #{path} && bundle exec #{core_cmd}"
end
# alternate config tests
path = File.join(base, 'rails_3_0')
- cmd = "cd #{path} && AA_CONFIG=2 bundle exec rake"
- puts cmd
- puts `#{cmd}`
+ cmds << "cd #{path} && AA_CONFIG=2 bundle exec #{core_cmd}"
+ cmds.each do |cmd|
+ puts cmd
+ puts `#{cmd}`
+ puts
+ end
end
desc 'Run a local copy of jekyll for previewing the documentation site.'
@@ -45,10 +45,11 @@ def self.template_file(template_name)
"#{File.dirname(__FILE__)}/views/#{template_name}.html.erb"
end
- attr_reader :base_settings, :controller_class, :form_settings,
- :index_settings, :model_class, :show_settings
- attr_accessor :actions, :custom_destroy, :default_search_matches_on
- attr_writer :model_class_name
+ attr_reader :added_default_search_matches, :base_settings,
+ :controller_class, :form_settings, :index_settings,
+ :model_class, :show_settings
+ attr_accessor :actions, :custom_destroy
+ attr_writer :default_search_matches_on, :model_class_name
def initialize(controller_class, model_class)
@controller_class, @model_class = controller_class, model_class
@@ -58,7 +59,7 @@ def initialize(controller_class, model_class)
@index_settings = IndexSettings.new self
@show_settings = ShowSettings.new self
@base_settings = BaseSettings.new self
- @default_search_matches_on = @model.searchable_columns.map &:name
+ @added_default_search_matches = []
end
def [](name)
@@ -88,10 +89,9 @@ def autocomplete_actions
if [:new, :create, :edit, :update].any? { |action|
actions.include?(action)
}
- defaults = @model.default_column_names
- accumulate_belongs_to_columns(defaults).each { |column|
- ac_actions << "autocomplete_#{column.name}".to_sym
- }
+ @model.belongs_to_associations.each do |assoc|
+ ac_actions << "autocomplete_#{assoc.name}".to_sym
+ end
end
if actions.include?(:index)
base_settings.all_polymorphic_types.each do |p_type|
@@ -156,6 +156,15 @@ def crudful_request_methods
def default_column_names
@model.default_column_names
end
+
+ def default_search_matches_on
+ if @default_search_matches_on
+ @default_search_matches_on
+ else
+ @model.searchable_columns.map(&:name).
+ concat(added_default_search_matches)
+ end
+ end
def method_missing(meth, *args)
if crudful_request_methods.include?(meth) and args.size == 1
@@ -306,11 +306,21 @@ def columns(*c)
def default_search_matches_on(*includes)
if includes.empty?
- @admin_assistant.default_search_matches_on
+ DefaultSearchMatchesOn.new(@admin_assistant)
else
@admin_assistant.default_search_matches_on = includes
end
end
+
+ class DefaultSearchMatchesOn
+ def initialize(admin_assistant)
+ @admin_assistant = admin_assistant
+ end
+
+ def <<(addition)
+ @admin_assistant.added_default_search_matches << addition
+ end
+ end
end
end
@@ -10,7 +10,7 @@ GIT
PATH
remote: ../../admin_assistant
specs:
- admin_assistant (2.2.3)
+ admin_assistant (2.2.7)
dynamic_form
will_paginate (~> 3.0)
@@ -87,7 +87,7 @@ GEM
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.29)
- will_paginate (3.0.2)
+ will_paginate (3.0.3)
PLATFORMS
ruby
@@ -10,7 +10,7 @@ GIT
PATH
remote: ../../admin_assistant
specs:
- admin_assistant (2.2.3)
+ admin_assistant (2.2.7)
dynamic_form
will_paginate (~> 3.0)
@@ -122,7 +122,7 @@ GEM
uglifier (1.0.2)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
- will_paginate (3.0.2)
+ will_paginate (3.0.3)
PLATFORMS
ruby

0 comments on commit fa06e57

Please sign in to comment.