meta_search 1.0.6 → 1.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -322,10 +322,6 @@ your controller. The other required parameter is the attribute name itself. Opti
322
322
  you can provide a string as a 3rd parameter to override the default link name, and then
323
323
  additional hashed for the +options+ and +html_options+ hashes for link_to.
324
324
 
325
- By default, the link that is created will sort by the given column in ascending order when first clicked. If you'd like to reverse this (so the first click sorts the results in descending order), you can pass +:default_order => :desc+ in the options hash, like so:
326
-
327
- <%= sort_link @search, :ratings, "Highest Rated", :default_order => :desc %>
328
-
329
325
  You can sort by more than one column as well, by creating a link like:
330
326
 
331
327
  <%= sort_link :name_and_salary %>
data/Rakefile CHANGED
@@ -15,10 +15,9 @@ begin
15
15
  gem.homepage = "http://metautonomo.us/projects/metasearch/"
16
16
  gem.authors = ["Ernie Miller"]
17
17
  gem.add_development_dependency "shoulda"
18
- gem.add_dependency "activerecord", "~> 3.0.2"
19
- gem.add_dependency "activesupport", "~> 3.0.2"
20
- gem.add_dependency "actionpack", "~> 3.0.2"
21
- gem.add_dependency "arel", "~> 2.0.2"
18
+ gem.add_dependency "activerecord", "~> 3.1.0.alpha"
19
+ gem.add_dependency "activesupport", "~> 3.1.0.alpha"
20
+ gem.add_dependency "actionpack", "~> 3.1.0.alpha"
22
21
  gem.post_install_message = <<END
23
22
 
24
23
  *** Thanks for installing MetaSearch! ***
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.6
1
+ 1.1.0.pre
@@ -35,7 +35,7 @@ module MetaSearch
35
35
  @options = opts # Let's just hang on to other options for use in authorization blocks
36
36
  @join_type = opts[:join_type] || Arel::Nodes::OuterJoin
37
37
  @join_type = get_join_type(@join_type)
38
- @join_dependency = build_join_dependency
38
+ @join_dependency = build_join_dependency(@relation)
39
39
  @search_attributes = {}
40
40
  @errors = ActiveModel::Errors.new(self)
41
41
  end
@@ -51,12 +51,7 @@ module MetaSearch
51
51
  def get_attribute(name, parent = @join_dependency.join_base)
52
52
  attribute = nil
53
53
  if get_column(name, parent.active_record)
54
- if parent.is_a?(ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation)
55
- relation = parent.relation.is_a?(Array) ? parent.relation.last : parent.relation
56
- attribute = relation[name]
57
- else
58
- attribute = @relation.arel_table[name]
59
- end
54
+ attribute = parent.table[name]
60
55
  elsif (segments = name.to_s.split(/_/)).size > 1
61
56
  remainder = []
62
57
  found_assoc = nil
@@ -252,53 +247,58 @@ module MetaSearch
252
247
  type
253
248
  end
254
249
 
255
- def build_or_find_association(association, parent = @join_dependency.join_base, klass = nil)
250
+ def build_or_find_association(name, parent = @join_dependency.join_base, klass = nil)
256
251
  found_association = @join_dependency.join_associations.detect do |assoc|
257
- assoc.reflection.name == association.to_sym &&
258
- assoc.reflection.klass == klass &&
259
- assoc.parent == parent
252
+ assoc.reflection.name == name &&
253
+ assoc.parent == parent &&
254
+ (!klass || assoc.reflection.klass == klass)
260
255
  end
261
256
  unless found_association
262
- @join_dependency.send(:build_with_metasearch, association, parent, @join_type, klass)
257
+ @join_dependency.send(:build_polymorphic, name.to_sym, parent, @join_type, klass)
263
258
  found_association = @join_dependency.join_associations.last
259
+ # Leverage the stashed association functionality in AR
264
260
  @relation = @relation.joins(found_association)
265
261
  end
262
+
266
263
  found_association
267
264
  end
268
265
 
269
- def build_join_dependency
270
- joins = @relation.joins_values.map {|j| j.respond_to?(:strip) ? j.strip : j}.uniq
271
-
272
- association_joins = joins.select do |j|
273
- [Hash, Array, Symbol].include?(j.class) && !array_of_strings?(j)
274
- end
275
-
276
- stashed_association_joins = joins.select do |j|
277
- j.is_a?(ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation)
266
+ def build_join_dependency(relation)
267
+ buckets = relation.joins_values.group_by do |join|
268
+ case join
269
+ when String
270
+ 'string_join'
271
+ when Hash, Symbol, Array
272
+ 'association_join'
273
+ when ::ActiveRecord::Associations::JoinDependency::JoinAssociation
274
+ 'stashed_join'
275
+ when Arel::Nodes::Join
276
+ 'join_node'
277
+ else
278
+ raise 'unknown class: %s' % join.class.name
279
+ end
278
280
  end
279
281
 
280
- non_association_joins = (joins - association_joins - stashed_association_joins)
281
- custom_joins = custom_join_sql(*non_association_joins)
282
+ association_joins = buckets['association_join'] || []
283
+ stashed_association_joins = buckets['stashed_join'] || []
284
+ join_nodes = buckets['join_node'] || []
285
+ string_joins = (buckets['string_join'] || []).map { |x|
286
+ x.strip
287
+ }.uniq
282
288
 
283
- ActiveRecord::Associations::ClassMethods::JoinDependency.new(@base, association_joins, custom_joins)
284
- end
289
+ join_list = relation.send :custom_join_ast, relation.table.from(relation.table), string_joins
285
290
 
286
- def custom_join_sql(*joins)
287
- arel = @relation.table
288
- joins.each do |join|
289
- next if join.blank?
291
+ join_dependency = ::ActiveRecord::Associations::JoinDependency.new(
292
+ relation.klass,
293
+ association_joins,
294
+ join_list
295
+ )
290
296
 
291
- case join
292
- when Hash, Array, Symbol
293
- if array_of_strings?(join)
294
- join_string = join.join(' ')
295
- arel = arel.join(join_string)
296
- end
297
- else
298
- arel = arel.join(join)
299
- end
297
+ join_nodes.each do |join|
298
+ join_dependency.alias_tracker.aliased_name_for(join.left.name.downcase)
300
299
  end
301
- arel.joins(arel)
300
+
301
+ join_dependency.graft(*stashed_association_joins)
302
302
  end
303
303
 
304
304
  def get_join_type(opt_join)
@@ -16,27 +16,14 @@ module MetaSearch
16
16
  # <%= sort_link @search, :name, 'Company Name' %>
17
17
  # <%= sort_link @search, :name, :class => 'name_sort' %>
18
18
  # <%= sort_link @search, :name, 'Company Name', :class => 'company_name_sort' %>
19
- # <%= sort_link @search, :name, :default_order => :desc %>
20
- # <%= sort_link @search, :name, 'Company Name', :default_order => :desc %>
21
- # <%= sort_link @search, :name, :class => 'name_sort', :default_order => :desc %>
22
- # <%= sort_link @search, :name, 'Company Name', :class => 'company_name_sort', :default_order => :desc %>
23
-
24
19
  def sort_link(builder, attribute, *args)
25
20
  raise ArgumentError, "Need a MetaSearch::Builder search object as first param!" unless builder.is_a?(MetaSearch::Builder)
26
21
  attr_name = attribute.to_s
27
22
  name = (args.size > 0 && !args.first.is_a?(Hash)) ? args.shift.to_s : builder.base.human_attribute_name(attr_name)
28
23
  prev_attr, prev_order = builder.search_attributes['meta_sort'].to_s.split('.')
29
-
30
- options = args.first.is_a?(Hash) ? args.shift : {}
31
24
  current_order = prev_attr == attr_name ? prev_order : nil
32
-
33
- if options[:default_order] == :desc
34
- new_order = current_order == 'desc' ? 'asc' : 'desc'
35
- else
36
- new_order = current_order == 'asc' ? 'desc' : 'asc'
37
- end
38
- options.delete(:default_order)
39
-
25
+ new_order = current_order == 'asc' ? 'desc' : 'asc'
26
+ options = args.first.is_a?(Hash) ? args.shift : {}
40
27
  html_options = args.first.is_a?(Hash) ? args.shift : {}
41
28
  css = ['sort_link', current_order].compact.join(' ')
42
29
  html_options[:class] = [css, html_options[:class]].compact.join(' ')
@@ -63,4 +50,4 @@ module MetaSearch
63
50
  end
64
51
  end
65
52
  end
66
- end
53
+ end
@@ -2,90 +2,93 @@ module MetaSearch
2
2
 
3
3
  module JoinDependency
4
4
 
5
+ class JoinAssociation < ::ActiveRecord::Associations::JoinDependency::JoinAssociation
6
+
7
+ def initialize(reflection, join_dependency, parent = nil, polymorphic_class = nil)
8
+ if polymorphic_class && ::ActiveRecord::Base > polymorphic_class
9
+ swapping_reflection_klass(reflection, polymorphic_class) do |reflection|
10
+ super(reflection, join_dependency, parent)
11
+ end
12
+ else
13
+ super(reflection, join_dependency, parent)
14
+ end
15
+ end
16
+
17
+ def swapping_reflection_klass(reflection, klass)
18
+ reflection = reflection.clone
19
+ original_polymorphic = reflection.options.delete(:polymorphic)
20
+ reflection.instance_variable_set(:@klass, klass)
21
+ yield reflection
22
+ ensure
23
+ reflection.options[:polymorphic] = original_polymorphic
24
+ end
25
+
26
+ def ==(other)
27
+ super && active_record == other.active_record
28
+ end
29
+
30
+ def build_constraint(reflection, table, key, foreign_table, foreign_key)
31
+ if reflection.options[:polymorphic]
32
+ super.and(
33
+ foreign_table[reflection.foreign_type].eq(reflection.klass.name)
34
+ )
35
+ else
36
+ super
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ # Yes, I'm using alias_method_chain here. No, I don't feel too
43
+ # bad about it. JoinDependency, or, to call it by its full proper
44
+ # name, ::ActiveRecord::Associations::JoinDependency, is one of the
45
+ # most "for internal use only" chunks of ActiveRecord.
5
46
  def self.included(base)
6
47
  base.class_eval do
7
- alias_method_chain :graft, :metasearch
48
+ alias_method_chain :graft, :meta_search
8
49
  end
9
50
  end
10
51
 
11
- def graft_with_metasearch(*associations)
52
+ def graft_with_meta_search(*associations)
12
53
  associations.each do |association|
13
54
  join_associations.detect {|a| association == a} ||
14
- (
15
- association.class == MetaSearch::PolymorphicJoinAssociation ?
16
- build_with_metasearch(association.reflection.name, association.find_parent_in(self) || join_base, association.join_type, association.reflection.klass) :
17
- build(association.reflection.name, association.find_parent_in(self) || join_base, association.join_type)
18
- )
55
+ build_polymorphic(association.reflection.name, association.find_parent_in(self) || join_base, association.join_type, association.reflection.klass)
19
56
  end
20
57
  self
21
58
  end
22
59
 
23
- protected
60
+ # Should only be called by MetaSearch, and only with a single association name
61
+ def build_polymorphic(association, parent = nil, join_type = Arel::OuterJoin, klass = nil)
62
+ parent ||= join_parts.last
63
+ reflection = parent.reflections[association] or
64
+ raise ::ActiveRecord::ConfigurationError, "Association named '#{ association }' was not found; perhaps you misspelled it?"
65
+ unless join_association = find_join_association_respecting_polymorphism(reflection, parent, klass)
66
+ @reflections << reflection
67
+ join_association = build_join_association_respecting_polymorphism(reflection, parent, klass)
68
+ join_association.join_type = join_type
69
+ @join_parts << join_association
70
+ cache_joined_association(join_association)
71
+ end
24
72
 
25
- def build_with_metasearch(associations, parent = nil, join_type = Arel::Nodes::InnerJoin, polymorphic_class = nil)
26
- parent ||= @joins.last
27
- case associations
28
- when Symbol, String
29
- reflection = parent.reflections[associations.to_s.intern] or
30
- raise ConfigurationError, "Association named '#{ associations }' was not found; perhaps you misspelled it?"
31
- unless (association = find_join_association(reflection, parent)) && (!polymorphic_class || association.active_record == polymorphic_class)
32
- @reflections << reflection
33
- if reflection.options[:polymorphic]
34
- raise ArgumentError, "You can't create a polymorphic belongs_to join without specifying the polymorphic class!" unless polymorphic_class
35
- association = PolymorphicJoinAssociation.new(reflection, self, polymorphic_class, parent)
36
- else
37
- association = build_join_association(reflection, parent)
38
- end
39
- association.join_type = join_type
40
- @joins << association
41
- end
73
+ join_association
74
+ end
75
+
76
+ def find_join_association_respecting_polymorphism(reflection, parent, klass)
77
+ if association = find_join_association(reflection, parent)
78
+ unless reflection.options[:polymorphic]
42
79
  association
43
80
  else
44
- build(associations, parent, join_type)
81
+ association if association.active_record == klass
45
82
  end
46
83
  end
47
- end
48
-
49
- class PolymorphicJoinAssociation < ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation
50
-
51
- def initialize(reflection, join_dependency, polymorphic_class, parent = nil)
52
- reflection.check_validity!
53
- @active_record = polymorphic_class
54
- @cached_record = {}
55
- @join_dependency = join_dependency
56
- @parent = parent || join_dependency.join_base
57
- @reflection = reflection.clone
58
- @reflection.instance_variable_set(:"@klass", polymorphic_class)
59
- @aliased_prefix = "t#{ join_dependency.joins.size }"
60
- @parent_table_name = @parent.active_record.table_name
61
- @aliased_table_name = aliased_table_name_for(table_name)
62
- @join = nil
63
- @join_type = Arel::Nodes::InnerJoin
64
- end
65
-
66
- def ==(other)
67
- other.class == self.class &&
68
- other.reflection == reflection &&
69
- other.active_record == active_record &&
70
- other.parent == parent
71
84
  end
72
85
 
73
- def association_join
74
- return @join if @join
75
-
76
- aliased_table = Arel::Table.new(table_name, :as => @aliased_table_name, :engine => arel_engine)
77
- parent_table = Arel::Table.new(parent.table_name, :as => parent.aliased_table_name, :engine => arel_engine)
78
-
79
- @join = [
80
- aliased_table[options[:primary_key] || reflection.klass.primary_key].eq(parent_table[options[:foreign_key] || reflection.primary_key_name]),
81
- parent_table[options[:foreign_type]].eq(active_record.name)
82
- ]
83
-
84
- if options[:conditions]
85
- @join << interpolate_sql(sanitize_sql(options[:conditions], aliased_table_name))
86
+ def build_join_association_respecting_polymorphism(reflection, parent, klass = nil)
87
+ if reflection.options[:polymorphic] && klass
88
+ JoinAssociation.new(reflection, self, parent, klass)
89
+ else
90
+ JoinAssociation.new(reflection, self, parent)
86
91
  end
87
-
88
- @join
89
92
  end
90
93
  end
91
94
  end
data/lib/meta_search.rb CHANGED
@@ -15,7 +15,7 @@ module MetaSearch
15
15
  ['contains', 'like', 'matches', {:types => STRINGS, :predicate => :matches, :formatter => '"%#{param}%"'}],
16
16
  ['does_not_contain', 'nlike', 'not_matches', {:types => STRINGS, :predicate => :does_not_match, :formatter => '"%#{param}%"'}],
17
17
  ['starts_with', 'sw', {:types => STRINGS, :predicate => :matches, :formatter => '"#{param}%"'}],
18
- ['does_not_start_with', 'dnsw', {:types => STRINGS, :predicate => :does_not_match, :formatter => '"#{param}%"'}],
18
+ ['does_not_start_with', 'dnsw', {:types => STRINGS, :predicate => :does_not_match, :formatter => '"%#{param}%"'}],
19
19
  ['ends_with', 'ew', {:types => STRINGS, :predicate => :matches, :formatter => '"%#{param}"'}],
20
20
  ['does_not_end_with', 'dnew', {:types => STRINGS, :predicate => :does_not_match, :formatter => '"%#{param}"'}],
21
21
  ['greater_than', 'gt', {:types => (NUMBERS + DATES + TIMES), :predicate => :gt}],
@@ -53,7 +53,7 @@ require 'meta_search/helpers'
53
53
 
54
54
  I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'meta_search', 'locale', '*.yml')]
55
55
 
56
- ActiveRecord::Associations::ClassMethods::JoinDependency.send(:include, MetaSearch::JoinDependency)
56
+ ActiveRecord::Associations::JoinDependency.send(:include, MetaSearch::JoinDependency)
57
57
  ActiveRecord::Base.send(:include, MetaSearch::Searches::ActiveRecord)
58
58
  ActionView::Helpers::FormBuilder.send(:include, MetaSearch::Helpers::FormBuilder)
59
59
  ActionController::Base.helper(MetaSearch::Helpers::UrlHelper)
data/meta_search.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{meta_search}
8
- s.version = "1.0.5"
8
+ s.version = "1.1.0.pre"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Ernie Miller}]
12
- s.date = %q{2011-05-05}
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ernie Miller"]
12
+ s.date = %q{2011-05-26}
13
13
  s.description = %q{
14
14
  Allows simple search forms to be created against an AR3 model
15
15
  and its associations, has useful view helpers for sort links
@@ -70,8 +70,8 @@ you're feeling especially appreciative. It'd help me justify this
70
70
  "open source" stuff to my lovely wife. :)
71
71
 
72
72
  }
73
- s.require_paths = [%q{lib}]
74
- s.rubygems_version = %q{1.8.0}
73
+ s.require_paths = ["lib"]
74
+ s.rubygems_version = %q{1.7.2}
75
75
  s.summary = %q{Object-based searching (and more) for simply creating search forms.}
76
76
 
77
77
  if s.respond_to? :specification_version then
@@ -79,23 +79,20 @@ you're feeling especially appreciative. It'd help me justify this
79
79
 
80
80
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
81
81
  s.add_development_dependency(%q<shoulda>, [">= 0"])
82
- s.add_runtime_dependency(%q<activerecord>, ["~> 3.0.2"])
83
- s.add_runtime_dependency(%q<activesupport>, ["~> 3.0.2"])
84
- s.add_runtime_dependency(%q<actionpack>, ["~> 3.0.2"])
85
- s.add_runtime_dependency(%q<arel>, ["~> 2.0.2"])
82
+ s.add_runtime_dependency(%q<activerecord>, ["~> 3.1.0.alpha"])
83
+ s.add_runtime_dependency(%q<activesupport>, ["~> 3.1.0.alpha"])
84
+ s.add_runtime_dependency(%q<actionpack>, ["~> 3.1.0.alpha"])
86
85
  else
87
86
  s.add_dependency(%q<shoulda>, [">= 0"])
88
- s.add_dependency(%q<activerecord>, ["~> 3.0.2"])
89
- s.add_dependency(%q<activesupport>, ["~> 3.0.2"])
90
- s.add_dependency(%q<actionpack>, ["~> 3.0.2"])
91
- s.add_dependency(%q<arel>, ["~> 2.0.2"])
87
+ s.add_dependency(%q<activerecord>, ["~> 3.1.0.alpha"])
88
+ s.add_dependency(%q<activesupport>, ["~> 3.1.0.alpha"])
89
+ s.add_dependency(%q<actionpack>, ["~> 3.1.0.alpha"])
92
90
  end
93
91
  else
94
92
  s.add_dependency(%q<shoulda>, [">= 0"])
95
- s.add_dependency(%q<activerecord>, ["~> 3.0.2"])
96
- s.add_dependency(%q<activesupport>, ["~> 3.0.2"])
97
- s.add_dependency(%q<actionpack>, ["~> 3.0.2"])
98
- s.add_dependency(%q<arel>, ["~> 2.0.2"])
93
+ s.add_dependency(%q<activerecord>, ["~> 3.1.0.alpha"])
94
+ s.add_dependency(%q<activesupport>, ["~> 3.1.0.alpha"])
95
+ s.add_dependency(%q<actionpack>, ["~> 3.1.0.alpha"])
99
96
  end
100
97
  end
101
98
 
@@ -6,9 +6,9 @@ dt_<%= n %>:
6
6
  int : <%= n ** 3 %>
7
7
  flt : <%= n.to_f / 2.0 %>
8
8
  dec : <%= n.to_f ** (n + 0.1) %>
9
- dtm : <%= (Time.local(2009, 12, 24) + 86400 * n).in_time_zone.to_s(:db) %>
10
- tms : <%= (Time.local(2009, 12, 24) + 86400 * n).in_time_zone.to_s(:db) %>
11
- tim : <%= Time.local(2000, 01, 01, n+8, n).in_time_zone.to_s(:db) %>
9
+ dtm : <%= (Time.utc(2009, 12, 24) + 86400 * n).to_s(:db) %>
10
+ tms : <%= (Time.utc(2009, 12, 24) + 86400 * n).to_s(:db) %>
11
+ tim : <%= Time.utc(2000, 01, 01, n+8, n).to_s(:db) %>
12
12
  dat : <%= (Date.new(2009, 12, 24) + n).strftime("%Y-%m-%d") %>
13
13
  bin : <%= "BLOB#{n}" * n %>
14
14
  bln : <%= n % 2 > 0 ? true : false %>
data/test/helper.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
3
  require 'shoulda'
4
- require 'active_support/time'
5
4
  require 'active_record'
6
5
  require 'active_record/fixtures'
7
6
  require 'action_view'
@@ -24,7 +23,7 @@ ActiveRecord::Base.silence do
24
23
  load File.join(FIXTURES_PATH, 'schema.rb')
25
24
  end
26
25
 
27
- Fixtures.create_fixtures(FIXTURES_PATH, ActiveRecord::Base.connection.tables)
26
+ ActiveRecord::Fixtures.create_fixtures(FIXTURES_PATH, ActiveRecord::Base.connection.tables)
28
27
 
29
28
  I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'locales', '*.yml')]
30
29
 
@@ -6,18 +6,34 @@ class TestViewHelpers < ActionView::TestCase
6
6
  tests MetaSearch::Helpers::FormHelper
7
7
  include MetaSearch::Helpers::UrlHelper
8
8
 
9
- router = ActionDispatch::Routing::RouteSet.new
10
- router.draw do
11
- resources :developers
12
- resources :companies
13
- resources :projects
14
- resources :notes
15
- match ':controller(/:action(/:id(.:format)))'
9
+ def self.router
10
+ @router ||= begin
11
+ router = ActionDispatch::Routing::RouteSet.new
12
+ router.draw do
13
+ resources :developers
14
+ resources :companies
15
+ resources :projects
16
+ resources :notes
17
+ match ':controller(/:action(/:id(.:format)))'
18
+ end
19
+ router
20
+ end
16
21
  end
22
+
17
23
  include router.url_helpers
18
24
 
25
+ # FIXME: figure out a cleaner way to get this behavior
19
26
  def setup
27
+ router = self.class.router
20
28
  @controller = ActionView::TestCase::TestController.new
29
+ @controller.instance_variable_set(:@_routes, router)
30
+ @controller.class_eval do
31
+ include router.url_helpers
32
+ end
33
+
34
+ @controller.view_context_class.class_eval do
35
+ include router.url_helpers
36
+ end
21
37
  end
22
38
 
23
39
  context "A search against Company and a search against Developer" do
@@ -305,21 +321,6 @@ class TestViewHelpers < ActionView::TestCase
305
321
  @s = Company.search
306
322
  end
307
323
 
308
- should "generate a sort link for descending order if set as the default order" do
309
- assert_match /name.desc/,
310
- sort_link(@s, :name, :controller => 'companies', :default_order => :desc)
311
- end
312
-
313
- should "generate a sort link for ascending order if set as the default order" do
314
- assert_match /name.asc/,
315
- sort_link(@s, :name, :controller => 'companies', :default_order => :asc)
316
- end
317
-
318
- should "generate a sort link for ascending order if default is specified incorectly" do
319
- assert_match /name.asc/,
320
- sort_link(@s, :name, :controller => 'companies', :default_order => :something_else)
321
- end
322
-
323
324
  context "sorted by name ascending" do
324
325
  setup do
325
326
  @s.meta_sort = 'name.asc'
@@ -335,53 +336,17 @@ class TestViewHelpers < ActionView::TestCase
335
336
  sort_link(@s, :created_at, :controller => 'companies')
336
337
  end
337
338
 
338
- should "generate a sort link for descending order if ascending order is the default" do
339
- assert_match /name.desc/,
340
- sort_link(@s, :name, :controller => 'companies', :default_order => :asc)
341
- end
342
-
343
- should "generate a sort link for descending order if descending order is the default" do
344
- assert_match /name.desc/,
345
- sort_link(@s, :name, :controller => 'companies', :default_order => :desc)
346
- end
347
-
348
- should "generate a sort link for descending order if default is specified incorrectly" do
349
- assert_match /name.desc/,
350
- sort_link(@s, :name, :controller => 'companies', :default_order => :something_else)
351
- end
352
-
353
339
  context "with existing search options" do
354
340
  setup do
355
341
  @s.name_contains = 'a'
356
342
  end
357
343
 
358
344
  should "maintain previous search options in its sort links" do
359
- assert_match /search\[name_contains\]=a/,
345
+ assert_match /search%5Bname_contains%5D=a/,
360
346
  sort_link(@s, :name, :controller => 'companies')
361
347
  end
362
348
  end
363
349
  end
364
-
365
- context "sorted by name descending" do
366
- setup do
367
- @s.meta_sort = 'name.desc'
368
- end
369
-
370
- should "generate a sort link for ascending order if descending order is the default" do
371
- assert_match /name.asc/,
372
- sort_link(@s, :name, :controller => 'companies', :default_order => :desc)
373
- end
374
-
375
- should "generate a sort link for ascending order if ascending order is the default" do
376
- assert_match /name.asc/,
377
- sort_link(@s, :name, :controller => 'companies', :default_order => :asc)
378
- end
379
-
380
- should "generate a sort link for ascending order if default is specified incorrectly" do
381
- assert_match /name.asc/,
382
- sort_link(@s, :name, :controller => 'companies', :default_order => :desc)
383
- end
384
- end
385
350
  end
386
351
 
387
352
  context "A developer search" do
@@ -410,10 +375,10 @@ class TestViewHelpers < ActionView::TestCase
410
375
  end
411
376
 
412
377
  should "maintain previous search options in its sort links" do
413
- assert_match /search\[name_contains\]=a/,
378
+ assert_match /search%5Bname_contains%5D=a/,
414
379
  sort_link(@s, :company_name, :controller => 'companies')
415
380
  end
416
381
  end
417
382
  end
418
383
  end
419
- end
384
+ end
metadata CHANGED
@@ -1,81 +1,71 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: meta_search
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.6
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: 6
5
+ version: 1.1.0.pre
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Ernie Miller
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-07 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2011-05-26 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
15
16
  name: shoulda
16
- requirement: &2158558880 !ruby/object:Gem::Requirement
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
17
19
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
22
24
  type: :development
23
- prerelease: false
24
- version_requirements: *2158558880
25
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
26
27
  name: activerecord
27
- requirement: &2158558360 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ~>
31
- - !ruby/object:Gem::Version
32
- version: 3.0.2
33
- type: :runtime
34
28
  prerelease: false
35
- version_requirements: *2158558360
36
- - !ruby/object:Gem::Dependency
37
- name: activesupport
38
- requirement: &2158557760 !ruby/object:Gem::Requirement
29
+ requirement: &id002 !ruby/object:Gem::Requirement
39
30
  none: false
40
- requirements:
31
+ requirements:
41
32
  - - ~>
42
- - !ruby/object:Gem::Version
43
- version: 3.0.2
33
+ - !ruby/object:Gem::Version
34
+ version: 3.1.0.alpha
44
35
  type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: activesupport
45
39
  prerelease: false
46
- version_requirements: *2158557760
47
- - !ruby/object:Gem::Dependency
48
- name: actionpack
49
- requirement: &2158557160 !ruby/object:Gem::Requirement
40
+ requirement: &id003 !ruby/object:Gem::Requirement
50
41
  none: false
51
- requirements:
42
+ requirements:
52
43
  - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 3.0.2
44
+ - !ruby/object:Gem::Version
45
+ version: 3.1.0.alpha
55
46
  type: :runtime
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: actionpack
56
50
  prerelease: false
57
- version_requirements: *2158557160
58
- - !ruby/object:Gem::Dependency
59
- name: arel
60
- requirement: &2158556560 !ruby/object:Gem::Requirement
51
+ requirement: &id004 !ruby/object:Gem::Requirement
61
52
  none: false
62
- requirements:
53
+ requirements:
63
54
  - - ~>
64
- - !ruby/object:Gem::Version
65
- version: 2.0.2
55
+ - !ruby/object:Gem::Version
56
+ version: 3.1.0.alpha
66
57
  type: :runtime
67
- prerelease: false
68
- version_requirements: *2158556560
69
- description: ! "\n Allows simple search forms to be created against an AR3 model\n
70
- \ and its associations, has useful view helpers for sort links\n and multiparameter
71
- fields as well.\n "
58
+ version_requirements: *id004
59
+ description: "\n Allows simple search forms to be created against an AR3 model\n and its associations, has useful view helpers for sort links\n and multiparameter fields as well.\n "
72
60
  email: ernie@metautonomo.us
73
61
  executables: []
62
+
74
63
  extensions: []
75
- extra_rdoc_files:
64
+
65
+ extra_rdoc_files:
76
66
  - LICENSE
77
67
  - README.rdoc
78
- files:
68
+ files:
79
69
  - .document
80
70
  - .gitmodules
81
71
  - CHANGELOG
@@ -117,39 +107,35 @@ files:
117
107
  - test/test_view_helpers.rb
118
108
  homepage: http://metautonomo.us/projects/metasearch/
119
109
  licenses: []
120
- post_install_message: ! '
121
-
122
- *** Thanks for installing MetaSearch! ***
123
-
124
- Be sure to check out http://metautonomo.us/projects/metasearch/ for a
125
-
126
- walkthrough of MetaSearch''s features, and click the donate button if
127
-
128
- you''re feeling especially appreciative. It''d help me justify this
129
110
 
130
- "open source" stuff to my lovely wife. :)
131
-
132
-
133
- '
111
+ post_install_message: "\n\
112
+ *** Thanks for installing MetaSearch! ***\n\
113
+ Be sure to check out http://metautonomo.us/projects/metasearch/ for a\n\
114
+ walkthrough of MetaSearch's features, and click the donate button if\n\
115
+ you're feeling especially appreciative. It'd help me justify this\n\
116
+ \"open source\" stuff to my lovely wife. :)\n\n"
134
117
  rdoc_options: []
135
- require_paths:
118
+
119
+ require_paths:
136
120
  - lib
137
- required_ruby_version: !ruby/object:Gem::Requirement
121
+ required_ruby_version: !ruby/object:Gem::Requirement
138
122
  none: false
139
- requirements:
140
- - - ! '>='
141
- - !ruby/object:Gem::Version
142
- version: '0'
143
- required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: "0"
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
128
  none: false
145
- requirements:
146
- - - ! '>='
147
- - !ruby/object:Gem::Version
148
- version: '0'
129
+ requirements:
130
+ - - ">"
131
+ - !ruby/object:Gem::Version
132
+ version: 1.3.1
149
133
  requirements: []
134
+
150
135
  rubyforge_project:
151
- rubygems_version: 1.8.5
136
+ rubygems_version: 1.7.2
152
137
  signing_key:
153
138
  specification_version: 3
154
139
  summary: Object-based searching (and more) for simply creating search forms.
155
140
  test_files: []
141
+