admin_data 1.1.8 → 1.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # admin_data works with both Rails 2.3.x and Rails 3. #
2
+
2
3
  # [Documentation](http://github.com/neerajdotname/admin_data/wiki) #
3
4
 
4
5
  # [Installing in a Rails3 application](https://github.com/neerajdotname/admin_data/wiki/Installation-and-Usage-information-for-a-Rails-3-application) #
@@ -7,14 +8,10 @@
7
8
  # [Live Demo](http://admin-data-test.heroku.com/admin_data) #
8
9
 
9
10
 
10
- * admin_data works as a gem with Rails 3.x project. Source for that resides in master branch.
11
- * admin_data works as a plugin with Rails 2.3.x project. Source code for that resides in branch called [rails2](https://github.com/neerajdotname/admin_data/tree/rails2) .
12
-
13
11
  #Test#
14
12
 
15
- cd _test/rails_app_ and read the instructions mentioned at README.md there.
13
+ ####cd _test/rails_app_ and read the instructions mentioned at README.md there.####
16
14
 
17
15
 
18
- ### License ###
19
16
 
20
- Dual licensed under the [MIT](http://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) and [GPL version 2](http://github.com/jquery/jquery/blob/master/GPL-LICENSE.txt) licenses.
17
+ [MIT](http://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) License
@@ -3,15 +3,18 @@ module AdminData
3
3
  class FeedController < ApplicationController
4
4
 
5
5
  def index
6
- render :text => "Usage: http://localhost:3000/admin_data/feed/<model name>" and return if params[:klasss].blank?
6
+ if params[:klasss].blank?
7
+ render :text => "Usage: http://localhost:3000/admin_data/feed/user replace user with your model name"
8
+ return
9
+ end
7
10
 
8
11
  begin
9
12
  @klass = Util.camelize_constantize(params[:klasss])
10
13
  @title = "Feeds from admin_data #{@klass.name}"
11
14
  @description = "feeds from AdminData #{@klass.name}"
12
15
  @records = @klass.find(:all, :order => "#{@klass.primary_key} desc", :limit => 100)
13
- rescue NameError => e
14
- render :text => "No constant was found with name #{params[:klasss]}" and return
16
+ rescue NameError
17
+ render :text => "No constant was found with name #{params[:klasss]}"
15
18
  end
16
19
  end
17
20
 
@@ -32,15 +35,10 @@ module AdminData
32
35
  return false
33
36
  end
34
37
 
35
- stored_userid = AdminData.config.feed_authentication_user_id
36
- stored_password = AdminData.config.feed_authentication_password
37
- perform_basic_authentication(stored_userid, stored_password, controller)
38
- end
39
-
40
- def perform_basic_authentication(stored_userid, stored_password, controller)
41
- controller.authenticate_or_request_with_http_basic do |input_userid, input_password|
42
- (input_userid == stored_userid) && (input_password == stored_password)
43
- end
38
+ userid = AdminData.config.feed_authentication_user_id
39
+ password = AdminData.config.feed_authentication_password
40
+ authenticator = AdminData::Authenticator.new(userid, password)
41
+ authenticator.verify(controller)
44
42
  end
45
43
 
46
44
  end
@@ -2,7 +2,7 @@ module AdminData
2
2
  class PublicController < ApplicationController
3
3
 
4
4
  def serve
5
- path = File.join(AdminData.public_dir,params[:file])
5
+ path = File.join(AdminData::LIBPATH, 'public', params[:file])
6
6
 
7
7
  unless File.expand_path(path) =~ /admin_data/
8
8
  render :nothing => true, :status => 404 and return
@@ -11,9 +11,12 @@ module AdminData
11
11
  opts = {:text => File.read(path), :cache => true}
12
12
 
13
13
  case params[:file]
14
- when /\.css$/i then opts[:content_type] = "text/css"
15
- when /\.js$/i then opts[:content_type] = "text/javascript"
16
- when /\.png$/i then opts[:content_type] = "image/png"
14
+ when /\.css$/i
15
+ opts[:content_type] = "text/css"
16
+ when /\.js$/i
17
+ opts[:content_type] = "text/javascript"
18
+ when /\.png$/i
19
+ opts[:content_type] = "image/png"
17
20
  else
18
21
  render :nothing => true, :status => 404 and return
19
22
  end
@@ -43,7 +43,7 @@ module AdminData
43
43
  format.js {
44
44
 
45
45
  unless hash[:errors].blank?
46
- file = "#{AdminData.plugin_dir}app/views/admin_data/search/search/_errors.html.erb"
46
+ file = File.join(AdminData::LIBPATH, '..', 'app','views', 'admin_data', 'search', 'search', '_errors.html.erb')
47
47
  render :file => file, :locals => {:errors => errors}
48
48
  return
49
49
  end
@@ -148,7 +148,7 @@ module AdminData
148
148
 
149
149
  if col.primary
150
150
  html << model.new_record? ? '(auto)' : model.id
151
- elsif get_reflection_for_column(klass, col) && AdminData.config.drop_down_for_associations[klass.name]
151
+ elsif get_reflection_for_column(klass, col) && AdminData.config.display_assoc?( klass.name )
152
152
  form_field_for_association_records(klass, col, f, html)
153
153
  else
154
154
  handle_column_type(col, html, model, column_value, f)
@@ -17,8 +17,8 @@ xml.rss(:version => "2.0" ){
17
17
  xml.description(desc)
18
18
  d = record.respond_to?(:created_at) ? record.created_at : Time.now
19
19
  xml.pubDate(d.strftime("%a, %d %b %Y %H:%M:%S %z"))
20
- xml.link(admin_data_on_k_path(:id => record, :klass => @klass.name))
21
- xml.guid(admin_data_on_k_path(:id => record, :klass => @klass.name))
20
+ xml.link(admin_data_url(:id => record, :klass => @klass.name))
21
+ xml.guid(admin_data_url(:id => record, :klass => @klass.name))
22
22
  end
23
23
  end
24
24
  }
data/config/routes.rb CHANGED
@@ -6,13 +6,12 @@ Rails.application.routes.draw do
6
6
 
7
7
  namespace(:admin_data) do
8
8
  scope :admin_data do
9
-
10
9
  controller "crud" do
11
- match '/klass/(:klass)', :to => :index, :as => :index, :via => :get
12
- match '/klass/(:klass)', :to => :create, :as => :index, :via => :post
13
- match '/klass/:klass/new', :to => :new, :as => :new, :via => :get
14
- match '/klass/:klass/:id/del', :to => :del, :as => :del, :via => :delete
15
- match '/klass/:klass/:id/edit', :to => :edit, :as => :edit, :via => :get
10
+ match '/klass/(:klass)', :to => :index, :as => :index, :via => :get
11
+ match '/klass/(:klass)', :to => :create, :as => :index, :via => :post
12
+ match '/klass/:klass/new', :to => :new, :as => :new, :via => :get
13
+ match '/klass/:klass/:id/del', :to => :del, :as => :del, :via => :delete
14
+ match '/klass/:klass/:id/edit', :to => :edit, :as => :edit, :via => :get
16
15
  match '/klass/:klass/:id', :to => :show, :via => :get
17
16
  match '/klass/:klass/:id', :to => :update, :via => :put
18
17
  match '/klass/:klass/:id', :to => :destroy, :via => :delete
@@ -24,11 +23,11 @@ Rails.application.routes.draw do
24
23
  end
25
24
 
26
25
  match '/table_structure/:klass' => "table_structure#index", :as => :table_structure
27
- match '/quick_search/:klass' => "search#quick_search", :as => :search
28
- match '/advance_search/:klass' => "search#advance_search", :as => :advance_search
26
+ match '/quick_search/:klass' => "search#quick_search", :as => :search
27
+ match '/advance_search/:klass' => "search#advance_search", :as => :advance_search
29
28
  match '/public/*file' => "public#serve"
30
- root :to => "home#index"
31
29
 
30
+ root :to => "home#index"
32
31
  end
33
32
  end
34
33
 
data/lib/admin_data.rb CHANGED
@@ -1,46 +1,21 @@
1
+ require 'admin_data/rails_version_check'
1
2
  require 'will_paginate'
2
- require 'admin_data/configuration'
3
3
 
4
4
  module AdminData
5
- LIBPATH = File.expand_path(::File.dirname(__FILE__)) + File::SEPARATOR
5
+ extend ActiveSupport::Autoload
6
6
 
7
- def self.plugin_dir
8
- File.expand_path(File.join(LIBPATH, '..')) + File::SEPARATOR
9
- end
7
+ LIBPATH = File.dirname(__FILE__)
10
8
 
11
- def self.public_dir
12
- File.expand_path(File.join(LIBPATH, 'public')) + File::SEPARATOR
13
- end
9
+ autoload :Configuration
10
+ autoload :Util
11
+ autoload :Config
12
+ autoload :ActiveRecordUtil
13
+ autoload :SetupConfig
14
+ autoload :DateUtil
15
+ autoload :Authenticator
14
16
 
15
- class << self
16
- # A configuration object that acts like a hash.
17
- # See AdminData::Configuration for details.
18
- attr_accessor :configuration
17
+ include SetupConfig
19
18
 
20
- # Call this method to modify defaults in initializer.
21
- #
22
- # @example
23
- # AdminData.config do |config|
24
- # config.number_of_records_per_page = 20
25
- # end
26
- def config
27
- self.configuration ||= Configuration.new
28
- block_given? ? yield(self.configuration) : self.configuration
29
- end
30
- end
31
-
32
- end
33
-
34
- if Rails.version >= '3.0'
35
- require 'admin_data/railtie'
36
- else
37
- raise "Please see documentation at http://github.com/neerajdotname/admin_data/wiki to find out how to use this gem with rails 2.3.x"
38
19
  end
39
20
 
40
- # move date_validation to inside admin_data
41
- require 'admin_data_date_validation'
42
-
43
- require 'admin_data/deprecation'
44
- require 'admin_data/extension'
45
- require 'admin_data/util'
46
- require 'admin_data/active_record_util'
21
+ require 'admin_data/railtie'
@@ -0,0 +1,15 @@
1
+ # HttpBasic authenticator for feed authentication
2
+ module AdminData
3
+ class Authenticator
4
+
5
+ def initialize(userid, password)
6
+ @userid = userid
7
+ @password = password
8
+ end
9
+
10
+ def verify(controller)
11
+ controller.authenticate_or_request_with_http_basic { |_userid, _password| (_userid == @userid) && (_password == @password) }
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,38 @@
1
+ # Following code takes care of providing a nice error
2
+ # message to users who are using old API
3
+ module AdminData
4
+
5
+ class Config
6
+ cattr_accessor :setting
7
+
8
+ def self.set=(input = {})
9
+
10
+ msg=<<EOF
11
+
12
+ AdminData API has changed in version 1.1 .
13
+
14
+ The changes are very minor.
15
+
16
+ Instead of
17
+
18
+ AdminData::Config.set = {
19
+ :find_conditions => ....
20
+ }
21
+
22
+ Now you need to write in following style
23
+
24
+ AdminData.config do |config|
25
+ config.find_conditions = ...
26
+ end
27
+
28
+ Please refer to documentation at
29
+ https://github.com/neerajdotname/admin_data/wiki/Customizing-admin_data-for-a-Rails-3-application
30
+ for more information.
31
+
32
+ EOF
33
+
34
+ raise msg
35
+ end
36
+
37
+ end
38
+ end
@@ -107,6 +107,20 @@ module AdminData
107
107
  @adapter_name = ActiveRecord::Base.connection.adapter_name
108
108
  @ignore_column_limit = false
109
109
  end
110
+
111
+ def display_assoc?( class_name )
112
+ case @drop_down_for_associations
113
+ when Hash
114
+ return @drop_down_for_associations[ class_name ]
115
+ when TrueClass, FalseClass
116
+ return @drop_down_for_associations
117
+ when NilClass
118
+ return false
119
+ else
120
+ raise "Configuration Error. #{@drop_down_for_associations} " \
121
+ "must be true, false or a Hash."
122
+ end
123
+ end
110
124
 
111
125
  end
112
126
 
@@ -0,0 +1,58 @@
1
+ require 'date'
2
+
3
+ module AdminData
4
+ class DateUtil
5
+
6
+ # returns a time object for the given input.
7
+ # validation is not done. It is assumed that client
8
+ # has done validation using .valid? method.
9
+ def self.valid?(input)
10
+ !!parse(input)
11
+ end
12
+
13
+ # Usage:
14
+ #
15
+ # parase('13-feb-2008') # => time object
16
+ # parse('13-February-2008') # => time object
17
+ # parse('13-February-2008') # => time object
18
+ # parse('99-Feb-2008') #=> false
19
+ #
20
+ def self.parse(input)
21
+ return false if input.blank?
22
+
23
+ input.strip!
24
+
25
+ # remove all the white space characters
26
+ input.gsub!(/\s/,'')
27
+
28
+ return false if input.length < 9
29
+
30
+ dd,mm,yyyy = input.split('-')
31
+ return false if dd.nil? || mm.nil? || yyyy.nil?
32
+
33
+ # month must be of atleast three characters
34
+ return false if mm.length < 3
35
+
36
+ mm = mm.downcase[0,3]
37
+
38
+ months = {'jan' => 1, 'feb' => 2, 'mar' => 3, 'apr' => 4, 'may' => 5, 'jun' => 6,
39
+ 'jul' => 7, 'aug' => 8, 'sep' => 9, 'oct' => 10, 'nov' => 11, 'dec' => 12 }
40
+
41
+ return false unless months.keys.include? mm
42
+
43
+ mm = months[mm].to_i
44
+ yyyy = yyyy.to_i
45
+ dd = dd.to_i
46
+
47
+ # validate date values
48
+ begin
49
+ Date.new(yyyy,mm,dd)
50
+ rescue
51
+ return false
52
+ end
53
+
54
+ Time.now.change(:year => yyyy, :month => mm, :day => dd, :hour => 0)
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,8 @@
1
+ unless Rails.version >= '3.0'
2
+ msg = []
3
+ msg << "It seems you are not using Rails 3."
4
+ msg << "Please see documentation at"
5
+ msg << "http://github.com/neerajdotname/admin_data/wiki"
6
+ msg << "to find out how to use this gem with rails 2.3.x"
7
+ raise msg.join(' ')
8
+ end
@@ -139,7 +139,7 @@ module Search
139
139
  def values_after_cast
140
140
  case operator
141
141
  when /(is_on|is_on_or_before_date|is_on_or_after_date)/
142
- AdminDataDateValidation.validate(operands)
142
+ AdminData::DateUtil.parse(operands)
143
143
  when /(is_equal_to|greater_than|less_than)/
144
144
  operands.to_i
145
145
  else
@@ -150,7 +150,7 @@ module Search
150
150
  def validate
151
151
  case operator
152
152
  when /(is_on|is_on_or_before_date|is_on_or_after_date)/
153
- "#{operands} is not a valid date" unless AdminDataDateValidation.validate(operands)
153
+ "#{operands} is not a valid date" unless AdminData::DateUtil.valid?(operands)
154
154
  when /(is_equal_to|greater_than|less_than)/
155
155
  unless operands.blank?
156
156
  "#{operands} is not a valid integer" unless operands =~ /^\d+$/
@@ -0,0 +1,24 @@
1
+ module AdminData
2
+
3
+ module SetupConfig
4
+ extend ActiveSupport::Concern
5
+
6
+ module ClassMethods
7
+
8
+ # See AdminData::Configuration for details.
9
+ attr_accessor :configuration
10
+
11
+ # Call this method to customize the behavior of admin_data .
12
+ #
13
+ # @example
14
+ # AdminData.config do |config|
15
+ # config.number_of_records_per_page = 20
16
+ # end
17
+ def config
18
+ self.configuration ||= Configuration.new
19
+ block_given? ? yield(configuration) : configuration
20
+ end
21
+ end
22
+
23
+ end
24
+ end
@@ -6,8 +6,7 @@ module AdminData
6
6
  tmp = view.get_value_for_column(column, model, :limit => nil)
7
7
  sum << [ column.name, (tmp.html_safe? ? tmp : view.send(:h,tmp)) ]
8
8
  end
9
- extension = Extension.show_info(model)
10
- data + extension
9
+ data
11
10
  end
12
11
 
13
12
  def self.custom_value_for_column(column, model)
@@ -1,3 +1,3 @@
1
1
  module AdminData
2
- VERSION = '1.1.8'
2
+ VERSION = '1.1.9'
3
3
  end
@@ -1,7 +1,5 @@
1
1
  AdminData.config do |config|
2
2
 
3
- config.number_of_records_per_page = 2
4
-
5
3
  config.is_allowed_to_view = lambda {|_| return true}
6
4
  config.is_allowed_to_update = lambda {|_| return true}
7
5
 
@@ -10,13 +8,8 @@ AdminData.config do |config|
10
8
 
11
9
  config.find_conditions = {'City' => lambda { |params| {:conditions => ["name =?", params[:id]] }}}
12
10
 
13
-
14
11
  config.column_settings = { 'City' => { :data => lambda { |model| model.send(:data).to_a.flatten.inspect } } }
15
12
 
16
- config.drop_down_for_associations = { 'PhoneNumber' => false}
17
-
18
13
  config.columns_order = {'Website' => [:dns_provider, :user_id] }
19
14
 
20
- config.column_headers = {'City' => {:id => 'ID', :name => 'City Name', :data => 'City Info'}}
21
-
22
15
  end
@@ -0,0 +1,61 @@
1
+ When /^configured to display only (\d*) records per page$/ do |max_recs|
2
+ AdminData.config do |config|
3
+ config.number_of_records_per_page = max_recs.to_i
4
+ end
5
+ end
6
+
7
+ def col_for( string )
8
+ string.gsub(/^\:/,'').downcase.to_sym
9
+ end
10
+
11
+ def add_to( config, param_sym, key1, key2, val)
12
+ hash = config.send( param_sym )
13
+ assign_sym = (param_sym.to_s + '=').to_sym
14
+ config.send( assign_sym, hash ||= {} )
15
+ hash[ key1 ] ||= {}
16
+ hash[ key1 ].store( key2, val )
17
+ end
18
+
19
+ # Assumes a table in the form:
20
+ # column, alias
21
+ # :city_name, City Name
22
+ When /^configured to rename (\w*) columns:$/ do |model, table|
23
+ @last_model = model
24
+ AdminData.config do |config|
25
+ table.hashes.each do |r|
26
+ add_to config, :column_headers, model, col_for(r['column']), r['alias']
27
+ end
28
+ end
29
+ end
30
+
31
+ When /^configured to display (\w*) column ([\:\w]*) as "([^"]*)"$/ do
32
+
33
+ |model, col_name, new_name|
34
+
35
+ @last_model = model
36
+ AdminData.config do |config|
37
+ add_to config, :column_headers, model, col_for(col_name), new_name
38
+ end
39
+ end
40
+
41
+ # Specify models to hide: Model1, Model2, Model3
42
+ Given /^configuration to (hide|show) the association drop down for ([\w\, ]*)$/ do |action,mods|
43
+ AdminData.config do |config|
44
+
45
+ hash = config.drop_down_for_associations
46
+ hash = {} if (hash == true || hash.nil?)
47
+
48
+ if action == "hide"
49
+ new_val = false
50
+ else
51
+ new_val = true
52
+ end
53
+
54
+ models = mods.split(', ')
55
+ models.each do |model|
56
+ hash.store( model.strip, new_val )
57
+ end
58
+
59
+ config.drop_down_for_associations = hash
60
+ end
61
+ end
@@ -1,3 +1,8 @@
1
- Given /^I am logged in through http basic authentication$/ do
2
- basic_auth('admin_data', 'welcome')
3
- end
1
+ AdminData::Authenticator.extend(
2
+ Module.new{
3
+ def verify(controller)
4
+ #TODO use rspec double code here. This is a very bad hack
5
+ true
6
+ end
7
+ }
8
+ )
@@ -1,12 +1,10 @@
1
1
  Given /^user config has defined additional_column phone_numbers$/ do
2
2
  AdminData.config.columns_order = AdminData.config.columns_order.merge('User' => [:id, :phone_numbers])
3
- AdminData.config.column_settings = AdminData.config.column_settings.merge('User' => { :phone_numbers => lambda {|model| model.phone_numbers.map {|r| r.number}.join(', ') } })
3
+ proc = lambda {|model| model.phone_numbers.map {|r| r.number}.join(', ') }
4
+ AdminData.config.column_settings = AdminData.config.column_settings.merge('User' => { :phone_numbers => proc })
4
5
  end
5
6
 
6
7
  Then /^table should have additional column phone_numbers with valid data$/ do
7
- AdminData.config.columns_order = AdminData.config.columns_order.merge('User' => nil)
8
- AdminData.config.column_settings = AdminData.config.column_settings.merge('User' => nil)
9
-
10
8
  data = tableish('table.table tr', 'th,td')
11
9
  data[0][0].should == "id"
12
10
  data[0][1].should == "phone_numbers"
@@ -16,6 +14,11 @@ Then /^table should have additional column phone_numbers with valid data$/ do
16
14
  assert_equal user.phone_numbers.map(&:number).join(', '),data[1][1]
17
15
  end
18
16
 
17
+ Then /^reset columns_order and column_settings for User$/ do
18
+ AdminData.config.columns_order = AdminData.config.columns_order.merge('User' => nil)
19
+ AdminData.config.column_settings = AdminData.config.column_settings.merge('User' => nil)
20
+ end
21
+
19
22
 
20
23
  Then /^I should see population_5000$/ do
21
24
  assert page.has_content?("[:population, 5000]")
@@ -1,9 +1,9 @@
1
- Then /^page should have text field css "(.*)" with user_id value$/ do |css_selector|
1
+ Then /^page should have (\w*) field css "(.*)" with user_id value$/ do |tag_name,css_selector|
2
2
  elem = page.find(css_selector)
3
+ elem.tag_name.should == tag_name
3
4
  elem.value.should == PhoneNumber.last.user.id.to_s
4
5
  end
5
6
 
6
-
7
7
  Then /^page should have id "remove_row_3"$/ do
8
8
  page.has_css?("remove_row_3")
9
9
  end
@@ -1,6 +1,6 @@
1
1
  # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
- # It is recommended to regenerate this file in the future when you upgrade to a
3
- # newer version of cucumber-rails. Consider adding your own code to a new file
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
4
  # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
5
  # files.
6
6
 
@@ -22,7 +22,7 @@ require 'capybara/session'
22
22
  # steps to use the XPath syntax.
23
23
  Capybara.default_selector = :css
24
24
 
25
- # If you set this to false, any error raised from within your app will bubble
25
+ # If you set this to false, any error raised from within your app will bubble
26
26
  # up to your step definition and out to cucumber unless you catch it somewhere
27
27
  # on the way. You can make Rails rescue errors and render error pages on a
28
28
  # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
@@ -34,15 +34,15 @@ Capybara.default_selector = :css
34
34
  ActionController::Base.allow_rescue = false
35
35
 
36
36
  # If you set this to true, each scenario will run in a database transaction.
37
- # You can still turn off transactions on a per-scenario basis, simply tagging
37
+ # You can still turn off transactions on a per-scenario basis, simply tagging
38
38
  # a feature or scenario with the @no-txn tag. If you are using Capybara,
39
39
  # tagging with @culerity or @javascript will also turn transactions off.
40
40
  #
41
41
  # If you set this to false, transactions will be off for all scenarios,
42
42
  # regardless of whether you use @no-txn or not.
43
43
  #
44
- # Beware that turning transactions off will leave data in your database
45
- # after each scenario, which can lead to hard-to-debug failures in
44
+ # Beware that turning transactions off will leave data in your database
45
+ # after each scenario, which can lead to hard-to-debug failures in
46
46
  # subsequent scenarios. If you do this, we recommend you create a Before
47
47
  # block that will explicitly put your database in a known state.
48
48
  Cucumber::Rails::World.use_transactional_fixtures = true
@@ -60,9 +60,8 @@ end
60
60
 
61
61
  require 'factory_girl'
62
62
  require Rails.root.join('test', 'factories')
63
- Dir[Rails.root.join('test', 'factories', '*.rb')].each {|f| require f}
63
+ Dir[Rails.root.join('test', 'factories', '*.rb')].each {|f| require f}
64
64
  require 'factory_girl/step_definitions'
65
65
  require 'shoulda'
66
66
 
67
- #Capybara.save_and_open_page_path = 'tmp'
68
- #Capybara.default_wait_time = 40
67
+ #Capybara.default_wait_time = 40
@@ -0,0 +1,9 @@
1
+
2
+ Before do
3
+
4
+ # Reset the configuration since it might have been modified by a step in
5
+ # another senario.
6
+ AdminData.configuration = nil
7
+ load File.join( Rails.root, 'config', 'initializers', 'admin_data.rb')
8
+
9
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admin_data
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 8
10
- version: 1.1.8
9
+ - 9
10
+ version: 1.1.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Neeraj Singh
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-11 00:00:00 -05:00
18
+ date: 2010-12-22 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -152,14 +152,16 @@ files:
152
152
  - config/routes.rb
153
153
  - lib/admin_data.rb
154
154
  - lib/admin_data/active_record_util.rb
155
+ - lib/admin_data/authenticator.rb
156
+ - lib/admin_data/config.rb
155
157
  - lib/admin_data/configuration.rb
156
- - lib/admin_data/deprecation.rb
157
- - lib/admin_data/extension.rb
158
+ - lib/admin_data/date_util.rb
159
+ - lib/admin_data/rails_version_check.rb
158
160
  - lib/admin_data/railtie.rb
159
161
  - lib/admin_data/search.rb
162
+ - lib/admin_data/setup_config.rb
160
163
  - lib/admin_data/util.rb
161
164
  - lib/admin_data/version.rb
162
- - lib/admin_data_date_validation.rb
163
165
  - lib/public/images/add.png
164
166
  - lib/public/images/no.png
165
167
  - lib/public/images/site.png
@@ -217,12 +219,14 @@ files:
217
219
  - test/rails_root/features/step_definitions/advance_search_steps.rb
218
220
  - test/rails_root/features/step_definitions/app_steps.rb
219
221
  - test/rails_root/features/step_definitions/async.rb
222
+ - test/rails_root/features/step_definitions/configuration_steps.rb
220
223
  - test/rails_root/features/step_definitions/crud_show_steps.rb
221
224
  - test/rails_root/features/step_definitions/feed_steps.rb
222
225
  - test/rails_root/features/step_definitions/quick_search_steps.rb
223
226
  - test/rails_root/features/step_definitions/util.rb
224
227
  - test/rails_root/features/step_definitions/web_steps.rb
225
228
  - test/rails_root/features/support/env.rb
229
+ - test/rails_root/features/support/hooks.rb
226
230
  - test/rails_root/features/support/paths.rb
227
231
  - test/rails_root/test/factories.rb
228
232
  - test/rails_root/test/performance/browsing_test.rb
@@ -290,12 +294,14 @@ test_files:
290
294
  - test/rails_root/features/step_definitions/advance_search_steps.rb
291
295
  - test/rails_root/features/step_definitions/app_steps.rb
292
296
  - test/rails_root/features/step_definitions/async.rb
297
+ - test/rails_root/features/step_definitions/configuration_steps.rb
293
298
  - test/rails_root/features/step_definitions/crud_show_steps.rb
294
299
  - test/rails_root/features/step_definitions/feed_steps.rb
295
300
  - test/rails_root/features/step_definitions/quick_search_steps.rb
296
301
  - test/rails_root/features/step_definitions/util.rb
297
302
  - test/rails_root/features/step_definitions/web_steps.rb
298
303
  - test/rails_root/features/support/env.rb
304
+ - test/rails_root/features/support/hooks.rb
299
305
  - test/rails_root/features/support/paths.rb
300
306
  - test/rails_root/test/factories.rb
301
307
  - test/rails_root/test/performance/browsing_test.rb
@@ -1,32 +0,0 @@
1
- class AdminData::Config
2
-
3
- cattr_accessor :setting
4
-
5
- def self.set=(input = {})
6
-
7
- msg=<<EOF
8
-
9
- AdminData API has changed in version 1.1 .
10
-
11
- The changes are very minor.
12
-
13
- Instead of
14
-
15
- AdminData::Config.set = {
16
- :find_conditions => ....
17
- }
18
-
19
- Now you need to write in following style
20
-
21
- AdminData.config do |config|
22
- config.find_conditions = ...
23
- end
24
-
25
- Please refer to documentation at https://github.com/neerajdotname/admin_data/wiki/Customizing-admin_data-for-a-Rails-3-application for more information.
26
-
27
- EOF
28
-
29
- raise msg
30
- end
31
-
32
- end
@@ -1,21 +0,0 @@
1
- class AdminData::Extension
2
-
3
- def self.show_info(model)
4
- return []
5
- klass = model.class
6
- if klass == User
7
-
8
- if (habtm_klasses = AdminData::ActiveRecordUtil.habtm_klasses_for(klass)).any?
9
- habtm_klasses.each do |k|
10
- name = k.columns.map(&:name).include?('name') ? :name : k.primary_key
11
- data << [ k.table_name, model.send(k.table_name).map{ |e|
12
- view.link_to(e.send(name), view.admin_data_path(:klass => k, :id => e.send(k.primary_key)))
13
- }.join(", ").html_safe ]
14
- end
15
- end
16
- end
17
-
18
- end # end of method
19
-
20
-
21
- end
@@ -1,79 +0,0 @@
1
- require 'date'
2
-
3
- class AdminDataDateValidation
4
-
5
- def self.validate_with_operator(input)
6
- return false if input.blank?
7
-
8
- input.strip!
9
-
10
- # replace multiple consecutive white spaces by one single whitespace
11
- input.gsub!(/\s+/,' ')
12
- operator, date = input.split
13
- return false if operator.nil?
14
- return false unless %w(> < >= <= =).include? operator
15
- validate(date)
16
- end
17
-
18
- # Usage:
19
- #
20
- # validate('13-feb-2008') # => time_object
21
- # validate('13-February-2008') # => time_object
22
- # validate('13-February-2008') # => time_object
23
- # validate('30-Feb-2008') #=> false
24
- #
25
- def self.validate(input)
26
- return false if input.nil?
27
-
28
- input.strip!
29
-
30
- # remove all the white space characters
31
- input.gsub!(/\s/,'')
32
-
33
- return false if input.length < 9
34
-
35
- dd,mm,yyyy = input.split('-')
36
- return false if dd.nil?
37
- return false if mm.nil?
38
- return false if yyyy.nil?
39
-
40
- # month must be of aleast three characters
41
- return false if mm.length < 3
42
-
43
- mm = mm.downcase
44
-
45
- #get only the first three characters
46
- mm = mm[0,3]
47
-
48
- months = {'jan' => 1,
49
- 'feb' => 2,
50
- 'mar' => 3,
51
- 'apr' => 4,
52
- 'may' => 5,
53
- 'jun' => 6,
54
- 'jul' => 7,
55
- 'aug' => 8,
56
- 'sep' => 9,
57
- 'oct' => 10,
58
- 'nov' => 11,
59
- 'dec' => 12 }
60
-
61
- return false unless months.keys.include? mm
62
-
63
- mm = months[mm]
64
- mm = mm.to_i
65
- yyyy = yyyy.to_i
66
- dd = dd.to_i
67
-
68
- # validate date values
69
- begin
70
- Date.new(yyyy,mm,dd)
71
- rescue => e
72
- return false
73
- end
74
-
75
- t = Time.now
76
- t.change(:year => yyyy, :month => mm, :day => dd, :hour => 0)
77
- end
78
-
79
- end