mongo_mapper_ext 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/Rakefile +5 -5
  2. data/lib/mongo_db_ext/micelaneous.rb +12 -0
  3. data/lib/mongo_mapper_ext/gems.rb +17 -2
  4. data/lib/mongo_mapper_ext/hacks/active_model.rb +16 -0
  5. data/lib/mongo_mapper_ext/hacks/fixes.rb +37 -0
  6. data/lib/mongo_mapper_ext/{micelaneous.rb → logging.rb} +30 -8
  7. data/lib/mongo_mapper_ext/migration.rb +1 -1
  8. data/lib/mongo_mapper_ext/mongo_mapper.rb +0 -25
  9. data/lib/mongo_mapper_ext/plugins/{attributes_cache.rb → attribute_cache.rb} +2 -1
  10. data/lib/mongo_mapper_ext/plugins/attribute_convertors.rb +79 -0
  11. data/lib/mongo_mapper_ext/plugins/belongs_to_with_counter_cache.rb +45 -0
  12. data/lib/mongo_mapper_ext/plugins/carrierwave.rb +60 -0
  13. data/lib/mongo_mapper_ext/plugins/{default_scope.rb → custom_scope.rb} +3 -2
  14. data/lib/mongo_mapper_ext/plugins/db_config.rb +84 -46
  15. data/lib/mongo_mapper_ext/plugins/micelaneous.rb +24 -68
  16. data/lib/mongo_mapper_ext/rad/file_uploader.rb +28 -0
  17. data/lib/mongo_mapper_ext/rad.rb +2 -0
  18. data/lib/mongo_mapper_ext/spec.rb +103 -0
  19. data/lib/mongo_mapper_ext/{migrate.rake → tasks.rb} +3 -15
  20. data/lib/mongo_mapper_ext.rb +41 -24
  21. data/readme.md +74 -2
  22. data/spec/attribute_convertors_spec.rb +71 -0
  23. data/spec/carrierwave_spec/plane.jpg +0 -0
  24. data/spec/carrierwave_spec.rb +42 -0
  25. data/spec/{scope_spec.rb → custom_scope_spec.rb} +26 -32
  26. data/spec/micelaneous_plugin_spec.rb +34 -20
  27. data/spec/micelaneous_spec.rb +105 -24
  28. data/spec/migration_spec.rb +8 -17
  29. data/spec/{mm_spec.rb → mongo_mapper_spec.rb} +0 -0
  30. data/spec/spec_helper.rb +2 -5
  31. data/spec/uploading_spec/ship.jpg +0 -0
  32. data/spec/uploading_spec//321/204/320/260/320/270/314/206/320/273 /321/201 /320/277/321/200/320/276/320/261/320/265/320/273/320/260/320/274/320/270.txt" +1 -0
  33. data/spec/uploading_spec.rb +49 -0
  34. metadata +164 -72
  35. data/lib/mongo_mapper_ext/db_config.rb +0 -67
  36. data/lib/mongo_mapper_ext/hacks/time_measuring.rb +0 -44
  37. data/lib/mongo_mapper_ext/spec/helper.rb +0 -61
@@ -1,61 +0,0 @@
1
- #
2
- # Disabling indexes in test environment
3
- #
4
- # if Object.const_defined?(:RAILS_ENV) and Object.const_get(:RAILS_ENV) != 'production'
5
- # MongoMapper::Plugins::Indexes::ClassMethods.class_eval do
6
- # def ensure_index(name_or_array, options={})
7
- # end
8
- # end
9
- # end
10
-
11
- if Object.const_defined?(:Crystal) and Crystal.respond_to?(:run)
12
- MongoMapper::Plugins::Indexes::ClassMethods.class_eval do
13
- alias_method :original_ensure_index, :ensure_index
14
- def ensure_index_stub *args; end
15
- end
16
-
17
- crystal.after :config do |config|
18
- if config.production?
19
- MongoMapper::Plugins::Indexes::ClassMethods.send :alias_method, :ensure_index, :original_ensure_index
20
- else
21
- MongoMapper::Plugins::Indexes::ClassMethods.send :alias_method, :ensure_index, :ensure_index_stub
22
- end
23
- end
24
- end
25
-
26
-
27
- #
28
- # Clear db before each test
29
- #
30
- RSpec::Core::ExampleGroup.class_eval do
31
- class << self
32
- def with_mongo_mapper
33
- before :each do
34
- MongoMapper.db_config.each do |db_alias, opt|
35
- db = MongoMapper.databases[db_alias]
36
- db.collection_names.each do |name|
37
- next if name =~ /^system\./
38
- db.collection(name).drop
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end
45
- # Spec::Runner.configure do |config|
46
- # config.before(:each) do
47
- # end
48
- # end
49
-
50
-
51
- #
52
- # Silence logger
53
- #
54
- MongoMapper.logger = Logger.new(nil)
55
- if defined? Paperclip
56
- Paperclip.class_eval do
57
- def self.logger
58
- @logger ||= Logger.new(nil)
59
- end
60
- end
61
- end