Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merged latest branches and started spec structure

  • Loading branch information...
commit 1f1d6c0e0fc9bc3bd2d3dd5b609c4561d816bec3 2 parents c46d451 + 9eb9afc
@kristianmandrup authored
View
1  .gitignore
@@ -15,3 +15,4 @@ spec/reports
test/tmp
test/version_tmp
tmp
+*.sublime*
View
12 Gemfile
@@ -1,4 +1,14 @@
-source 'https://rubygems.org'
+source :rubygems
# Specify your gem's dependencies in activeadmin-mongoid.gemspec
gemspec
+
+group :test do
+ gem "rspec", ">= 2.8.0"
+ gem 'rails', '~> 3.2'
+ # gem 'mongoid', '>= 2.4'
+ # gem 'bson', '>= 1.6'
+
+ gem 'mongoid', '~> 3.0' #, :git => 'git://github.com/mongoid/mongoid.git'
+end
+
View
6 lib/active_admin/mongoid/filter_form_builder.rb
@@ -8,14 +8,14 @@ def default_input_type(method, options = {})
return :string
when :integer
return :select if reflection_for(method.to_s.gsub('_id','').to_sym)
- return :numeric
+ :numeric
when :float, :decimal
- return :numeric
+ :numeric
end
elsif is_association?(method)
return :select
else # dirty but allows to create filters for hashes
- return :string
+ :string
end
end
View
2  lib/active_admin/mongoid/version.rb
@@ -1,5 +1,5 @@
module ActiveAdmin
module Mongoid
- VERSION = '0.0.1'
+ VERSION = '0.0.2'
end
end
View
15 spec/active_admin-mongoid/adaptor_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe ActiveAdmin::Mongoid::Adaptor do
+ describe ActiveAdmin::Mongoid::Adaptor::Search do
+ let(:search_adaptor) { ActiveAdmin::Mongoid::Adaptor::Search }
+
+ describe 'basic search adaptor' do
+ subject { search_adaptor.new object }
+
+ let(:object) { Post.new }
+
+ its(:base) { should == object }
+ end
+ end
+end
View
32 spec/spec_helper.rb
@@ -0,0 +1,32 @@
+require 'rspec'
+require 'mongoid'
+require 'active_admin/mongoid'
+
+# Requires supporting files with custom matchers and macros, etc,
+# in ./support/ and its subdirectories.
+Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
+
+puts "version: #{Mongoid::VERSION}"
+
+Mongoid.configure do |config|
+ Mongoid::VersionSetup.configure config
+end
+
+if RUBY_VERSION >= '1.9.2'
+ YAML::ENGINE.yamler = 'syck'
+end
+
+RSpec.configure do |config|
+ # config.mock_with(:mocha)
+
+ config.before(:each) do
+ Mongoid.purge!
+
+ # for Mongoid 2.x
+ # Mongoid.database.collections.each do |collection|
+ # unless collection.name =~ /^system\./
+ # collection.remove
+ # end
+ # end
+ end
+end
View
19 spec/support/mongoid.yml
@@ -0,0 +1,19 @@
+test:
+ database: activeadmin_mongoid_test
+ host: localhost
+ port: 27017
+ # slaves:
+ # - host: localhost
+ # port: 27018
+ # - host: localhost
+ # port: 27019
+ # allow_dynamic_fields: false
+ # include_root_in_json: true
+ # parameterize_keys: false
+ # persist_in_safe_mode: false
+ # raise_not_found_error: false
+ # reconnect_time: 5
+ # autocreate_indexes: false
+ # persist_types: false
+ # option_no_exist: false
+ # skip_version_check: false
View
37 spec/support/version_setup.rb
@@ -0,0 +1,37 @@
+module Mongoid
+ module VersionSetup
+ def self.configure config
+ version = Mongoid::VERSION
+ case
+ when version < '2'
+ raise ArgumentError, "Mongoid versions < 2 not supported"
+ when version < '3'
+ version_2 config
+ when version > '3'
+ version_3 config
+ end
+ end
+
+ def self.version_3 config
+ require 'moped'
+ config.connect_to('activeadmin_mongoid_test')
+ end
+
+ def self.version_2 config
+ require 'bson'
+
+ opts = YAML.load(File.read(File.dirname(__FILE__) + '/support/mongoid.yml'))["test"]
+ opts.delete("slaves") # no slaves support for version < 3
+ name = opts.delete("database")
+ host = opts.delete("host")
+ port = opts.delete("port")
+ config.master = begin
+ Mongo::Connection.new(host, port, opts).db(name)
+ rescue Mongo::ConnectionFailure
+ Mongo::Connection.new(host, '27017', opts).db(name)
+ end
+ config.logger = nil
+ config.allow_dynamic_fields = true
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.