the_jobbook_admin_data 1.3.0a
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/CHANGELOG.rdoc +284 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +121 -0
- data/Guardfile +14 -0
- data/MIT-LICENSE +20 -0
- data/README.md +37 -0
- data/README.rdoc +3 -0
- data/Rakefile +40 -0
- data/admin_data.gemspec +23 -0
- data/app/assets/images/add.png +0 -0
- data/app/assets/images/admin_data/.gitkeep +0 -0
- data/app/assets/images/no.png +0 -0
- data/app/assets/images/site.png +0 -0
- data/app/assets/images/sort_by_asc.jpg +0 -0
- data/app/assets/images/sort_by_desc.jpg +0 -0
- data/app/assets/images/sort_by_nothing.jpg +0 -0
- data/app/assets/javascripts/admin_data.js +18 -0
- data/app/assets/javascripts/admin_data/application.js +15 -0
- data/app/assets/javascripts/advance_search/act_on_result.js +45 -0
- data/app/assets/javascripts/advance_search/advance_search.js +83 -0
- data/app/assets/javascripts/advance_search/advance_search_structure.js +79 -0
- data/app/assets/javascripts/advance_search/ajaxify_advance_search.js +28 -0
- data/app/assets/javascripts/advance_search/build_first_row.js +8 -0
- data/app/assets/javascripts/advance_search/event_bindings.js +76 -0
- data/app/assets/javascripts/advance_search/global_ajax_setting.js +10 -0
- data/app/assets/javascripts/advance_search/sortby.js +14 -0
- data/app/assets/javascripts/advance_search/trigger_submit_on_domready.js +6 -0
- data/app/assets/javascripts/analytics/report.js +7 -0
- data/app/assets/javascripts/misc/drop_down_change.js +8 -0
- data/app/assets/javascripts/misc/js_util.js +58 -0
- data/app/assets/javascripts/misc/quick_search_input_focus.js +6 -0
- data/app/assets/javascripts/vendor/jquery-1.4.2.js +6240 -0
- data/app/assets/javascripts/vendor/jquery-ui-1.7.2.custom.min.js +298 -0
- data/app/assets/javascripts/vendor/jquery.ba-isjquery.js +21 -0
- data/app/assets/javascripts/vendor/jquery_form.js +814 -0
- data/app/assets/javascripts/vendor/log.js +9 -0
- data/app/assets/javascripts/vendor/rails.js +132 -0
- data/app/assets/stylesheets/admin_data.css +1141 -0
- data/app/assets/stylesheets/admin_data/application.css +13 -0
- data/app/assets/stylesheets/vendor/jquery-ui-1.7.2.custom.css +406 -0
- data/app/controllers/admin_data/application_controller.rb +107 -0
- data/app/controllers/admin_data/crud_controller.rb +100 -0
- data/app/controllers/admin_data/feed_controller.rb +48 -0
- data/app/controllers/admin_data/home_controller.rb +8 -0
- data/app/controllers/admin_data/migration_controller.rb +18 -0
- data/app/controllers/admin_data/public_controller.rb +28 -0
- data/app/controllers/admin_data/search_controller.rb +143 -0
- data/app/controllers/admin_data/table_structure_controller.rb +25 -0
- data/app/helpers/admin_data/application_helper.rb +320 -0
- data/app/views/admin_data/crud/association/_association_info.html.erb +11 -0
- data/app/views/admin_data/crud/association/_belongs_to_info.html.erb +7 -0
- data/app/views/admin_data/crud/association/_habtm_info.html.erb +7 -0
- data/app/views/admin_data/crud/association/_has_many_info.html.erb +7 -0
- data/app/views/admin_data/crud/association/_has_one_info.html.erb +6 -0
- data/app/views/admin_data/crud/edit.html.erb +36 -0
- data/app/views/admin_data/crud/misc/_form.html.erb +38 -0
- data/app/views/admin_data/crud/misc/_modify_record.html.erb +18 -0
- data/app/views/admin_data/crud/new.html.erb +25 -0
- data/app/views/admin_data/crud/show.html.erb +42 -0
- data/app/views/admin_data/feed/index.rss.builder +25 -0
- data/app/views/admin_data/home/index.html.erb +21 -0
- data/app/views/admin_data/migration/index.html.erb +18 -0
- data/app/views/admin_data/migration/jstest.html.erb +51 -0
- data/app/views/admin_data/search/advance_search.html.erb +1 -0
- data/app/views/admin_data/search/quick_search.html.erb +1 -0
- data/app/views/admin_data/search/search/_advance_search_form.html.erb +52 -0
- data/app/views/admin_data/search/search/_errors.html.erb +5 -0
- data/app/views/admin_data/search/search/_listing.html.erb +43 -0
- data/app/views/admin_data/search/search/_search_form.html.erb +27 -0
- data/app/views/admin_data/search/search/_title.html.erb +34 -0
- data/app/views/admin_data/shared/_breadcrum.html.erb +16 -0
- data/app/views/admin_data/shared/_drop_down_klasses.html.erb +4 -0
- data/app/views/admin_data/shared/_flash_message.html.erb +13 -0
- data/app/views/admin_data/shared/_header.html.erb +20 -0
- data/app/views/admin_data/shared/_powered_by.html.erb +6 -0
- data/app/views/admin_data/shared/_secondary_navigation.html.erb +26 -0
- data/app/views/admin_data/table_structure/index.html.erb +54 -0
- data/app/views/layouts/admin_data.html.erb +34 -0
- data/app/views/layouts/admin_data/application.html.erb +14 -0
- data/app/views/layouts/search.html.erb +71 -0
- data/config/routes.rb +32 -0
- data/lib/admin_data.rb +27 -0
- data/lib/admin_data/active_record_util.rb +102 -0
- data/lib/admin_data/analytics.rb +176 -0
- data/lib/admin_data/authenticator.rb +15 -0
- data/lib/admin_data/config.rb +38 -0
- data/lib/admin_data/configuration.rb +127 -0
- data/lib/admin_data/date_util.rb +58 -0
- data/lib/admin_data/engine.rb +17 -0
- data/lib/admin_data/model_finder.rb +15 -0
- data/lib/admin_data/rails_version_check.rb +8 -0
- data/lib/admin_data/search.rb +188 -0
- data/lib/admin_data/setup_config.rb +24 -0
- data/lib/admin_data/util.rb +102 -0
- data/lib/admin_data/version.rb +3 -0
- data/lib/tasks/admin_data_tasks.rake +4 -0
- data/script/rails +8 -0
- data/test/admin_data_test.rb +7 -0
- data/test/dummy/README.md +19 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +5 -0
- data/test/dummy/app/models/user.rb +3 -0
- data/test/dummy/app/models/user/student.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +15 -0
- data/test/dummy/config/boot.rb +13 -0
- data/test/dummy/config/cucumber.yml +9 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/database.yml.mysql +22 -0
- data/test/dummy/config/database.yml.pg +15 -0
- data/test/dummy/config/database.yml.sqlite3 +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +22 -0
- data/test/dummy/config/environments/production.rb +49 -0
- data/test/dummy/config/environments/test.rb +35 -0
- data/test/dummy/config/initializers/admin_data.rb +15 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/empty_spaces_to_nil.rb +10 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +9 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20091030202259_create_tables.rb +72 -0
- data/test/dummy/db/production.sqlite3 +1 -0
- data/test/dummy/db/schema.rb +23 -0
- data/test/dummy/db/seeds.rb +40 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/features/advance_search/boolean.feature +74 -0
- data/test/dummy/features/advance_search/datetime.feature +101 -0
- data/test/dummy/features/advance_search/delete_all.feature +20 -0
- data/test/dummy/features/advance_search/destroy_all.feature +20 -0
- data/test/dummy/features/advance_search/integer.feature +69 -0
- data/test/dummy/features/advance_search/multiple_rows.feature +87 -0
- data/test/dummy/features/advance_search/string.feature +130 -0
- data/test/dummy/features/crud.feature +50 -0
- data/test/dummy/features/crud_show.feature +56 -0
- data/test/dummy/features/feed.feature +13 -0
- data/test/dummy/features/home.feature +42 -0
- data/test/dummy/features/migration.feature +7 -0
- data/test/dummy/features/quick_search.feature +113 -0
- data/test/dummy/features/step_definitions/advance_search_steps.rb +13 -0
- data/test/dummy/features/step_definitions/app_steps.rb +36 -0
- data/test/dummy/features/step_definitions/async.rb +18 -0
- data/test/dummy/features/step_definitions/configuration_steps.rb +61 -0
- data/test/dummy/features/step_definitions/crud_show_steps.rb +37 -0
- data/test/dummy/features/step_definitions/feed_steps.rb +24 -0
- data/test/dummy/features/step_definitions/quick_search_steps.rb +68 -0
- data/test/dummy/features/step_definitions/util.rb +90 -0
- data/test/dummy/features/step_definitions/web_steps.rb +219 -0
- data/test/dummy/features/support/env.rb +66 -0
- data/test/dummy/features/support/hooks.rb +9 -0
- data/test/dummy/features/support/paths.rb +33 -0
- data/test/dummy/features/table_structure.feature +18 -0
- data/test/dummy/lib/tasks/.gitkeep +0 -0
- data/test/dummy/lib/tasks/cucumber.rake +53 -0
- data/test/dummy/lib/tasks/dbs.rake +30 -0
- data/test/dummy/lib/tasks/sample_cars.rake +18 -0
- data/test/dummy/public/.gitkeep +0 -0
- data/test/dummy/script/cucumber +10 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/factories.rb +30 -0
- data/test/dummy/test/test_helper.rb +7 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/admin_data/model_finder_test.rb +16 -0
- data/test/unit/car_test.rb +96 -0
- data/test/unit/user_phone_test.rb +19 -0
- metadata +253 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
# Maps a name to a path. Used by the
|
3
|
+
#
|
4
|
+
# When /^I go to (.+)$/ do |page_name|
|
5
|
+
#
|
6
|
+
# step definition in web_steps.rb
|
7
|
+
#
|
8
|
+
def path_to(page_name)
|
9
|
+
case page_name
|
10
|
+
|
11
|
+
when /the home\s?page/
|
12
|
+
'/'
|
13
|
+
|
14
|
+
# Add more mappings here.
|
15
|
+
# Here is an example that pulls values out of the Regexp:
|
16
|
+
#
|
17
|
+
# when /^(.*)'s profile page$/i
|
18
|
+
# user_profile_path(User.find_by_login($1))
|
19
|
+
|
20
|
+
else
|
21
|
+
begin
|
22
|
+
page_name =~ /the (.*) page/
|
23
|
+
path_components = $1.split(/\s+/)
|
24
|
+
self.send(path_components.push('path').join('_').to_sym)
|
25
|
+
rescue Object => e
|
26
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
27
|
+
"Now, go and add a mapping in #{__FILE__}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
World(NavigationHelpers)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Feature: table structure
|
2
|
+
|
3
|
+
Scenario: table structure
|
4
|
+
Given I visit quick_search page
|
5
|
+
When I follow "Table Structure"
|
6
|
+
Then I should see "Table name : users"
|
7
|
+
Then I should see following tabular attributes:
|
8
|
+
|Column Name | Type | Null | Default |
|
9
|
+
| id | integer | false | |
|
10
|
+
| first_name | string | true | |
|
11
|
+
| last_name | string | true | |
|
12
|
+
| age | integer | true | |
|
13
|
+
| data | text | true | |
|
14
|
+
| active | boolean | true | false |
|
15
|
+
| description | text | true | |
|
16
|
+
| born_at | datetime | true | |
|
17
|
+
| created_at | datetime | true | |
|
18
|
+
| updated_at | datetime | true | |
|
File without changes
|
@@ -0,0 +1,53 @@
|
|
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
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
+
# files.
|
6
|
+
|
7
|
+
|
8
|
+
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
9
|
+
|
10
|
+
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
11
|
+
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'cucumber/rake/task'
|
15
|
+
|
16
|
+
namespace :cucumber do
|
17
|
+
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
|
18
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
19
|
+
t.fork = true # You may get faster startup if you set this to false
|
20
|
+
t.profile = 'default'
|
21
|
+
end
|
22
|
+
|
23
|
+
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
|
24
|
+
t.binary = vendored_cucumber_bin
|
25
|
+
t.fork = true # You may get faster startup if you set this to false
|
26
|
+
t.profile = 'wip'
|
27
|
+
end
|
28
|
+
|
29
|
+
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
|
30
|
+
t.binary = vendored_cucumber_bin
|
31
|
+
t.fork = true # You may get faster startup if you set this to false
|
32
|
+
t.profile = 'rerun'
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Run all features'
|
36
|
+
task :all => [:ok, :wip]
|
37
|
+
end
|
38
|
+
desc 'Alias for cucumber:ok'
|
39
|
+
task :cucumber => 'cucumber:ok'
|
40
|
+
|
41
|
+
task :default => :cucumber
|
42
|
+
|
43
|
+
task :features => :cucumber do
|
44
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
45
|
+
end
|
46
|
+
rescue LoadError
|
47
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
48
|
+
task :cucumber do
|
49
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
namespace :db do
|
4
|
+
|
5
|
+
namespace :use do
|
6
|
+
|
7
|
+
desc 'set database.yml to sqlite3'
|
8
|
+
task :sqlite3 do
|
9
|
+
file = Rails.root.join('config', 'database.yml')
|
10
|
+
orig = Rails.root.join('config', 'database.yml.sqlite3')
|
11
|
+
FileUtils.cp(orig, file)
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'set database.yml to pg'
|
15
|
+
task :pg do
|
16
|
+
file = Rails.root.join('config', 'database.yml')
|
17
|
+
orig = Rails.root.join('config', 'database.yml.pg')
|
18
|
+
FileUtils.cp(orig, file)
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'set database.yml to mysql'
|
22
|
+
task :mysql do
|
23
|
+
file = Rails.root.join('config', 'database.yml')
|
24
|
+
orig = Rails.root.join('config', 'database.yml.mysql')
|
25
|
+
FileUtils.cp(orig, file)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
namespace :db do
|
2
|
+
|
3
|
+
desc 'populate cars'
|
4
|
+
task :sample_cars => :environment do
|
5
|
+
Car.delete_all
|
6
|
+
|
7
|
+
(1..400).to_a.each_with_index do |i, e|
|
8
|
+
i.times do
|
9
|
+
car = Car.new(:name => "car-#{i}")
|
10
|
+
puts i
|
11
|
+
car.created_at = i.send(:days).send(:ago)
|
12
|
+
car.save!
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
4
|
+
if vendored_cucumber_bin
|
5
|
+
load File.expand_path(vendored_cucumber_bin)
|
6
|
+
else
|
7
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
8
|
+
require 'cucumber'
|
9
|
+
load Cucumber::BINARY
|
10
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Factory.define :user do |f|
|
2
|
+
f.first_name 'Mary'
|
3
|
+
f.last_name 'Jane'
|
4
|
+
f.age 21
|
5
|
+
f.born_at {Time.parse('August 31 2010')}
|
6
|
+
end
|
7
|
+
|
8
|
+
Factory.define :website do |f|
|
9
|
+
f.url 'http://example.com'
|
10
|
+
f.association :user
|
11
|
+
end
|
12
|
+
|
13
|
+
Factory.define :phone_number do |f|
|
14
|
+
f.number '123-456-7890'
|
15
|
+
f.association :user
|
16
|
+
end
|
17
|
+
|
18
|
+
Factory.define :club do |f|
|
19
|
+
f.name 'sun-shine club'
|
20
|
+
f.association :user
|
21
|
+
end
|
22
|
+
|
23
|
+
Factory.define :newspaper do |f|
|
24
|
+
f.paper_id 'dc_express'
|
25
|
+
f.name 'DC Express'
|
26
|
+
end
|
27
|
+
|
28
|
+
Factory.define :city do |f|
|
29
|
+
f.name 'seattle'
|
30
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
+
|
12
|
+
# Load fixtures from the engine
|
13
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class AdminData::ModelFinderTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "list all model from app" do
|
6
|
+
expected = %w(User User::Student).sort
|
7
|
+
|
8
|
+
assert_equal expected, AdminData::ModelFinder.models
|
9
|
+
end
|
10
|
+
|
11
|
+
test "namespaced models" do
|
12
|
+
expected = %w(User::Student)
|
13
|
+
assert_equal expected, AdminData::ModelFinder.namespaced_models(User)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CarTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
=begin
|
6
|
+
def setup
|
7
|
+
Car.delete_all
|
8
|
+
new_time = Time.local(2011, 6, 23, 12, 0, 0)
|
9
|
+
Timecop.freeze(new_time)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_by_default_all_values_are_zero
|
13
|
+
now = Time.now.utc
|
14
|
+
result = AdminData::Analytics.daily_report(Car, now)
|
15
|
+
expected = []
|
16
|
+
expected << ["'2011-05-23'", 0] << ["'2011-05-24'", 0] << ["'2011-05-25'", 0] << ["'2011-05-26'", 0] << ["'2011-05-27'", 0]
|
17
|
+
expected << ["'2011-05-28'", 0] << ["'2011-05-29'", 0] << ["'2011-05-30'", 0] << ["'2011-05-31'", 0]
|
18
|
+
expected << ["'2011-06-01'", 0] << ["'2011-06-02'", 0]
|
19
|
+
expected << ["'2011-06-03'", 0] << ["'2011-06-04'", 0] << ["'2011-06-05'", 0] << ["'2011-06-06'", 0] << ["'2011-06-07'", 0]
|
20
|
+
expected << ["'2011-06-08'", 0] << ["'2011-06-09'", 0] << ["'2011-06-10'", 0] << ["'2011-06-11'", 0] << ["'2011-06-12'", 0]
|
21
|
+
expected << ["'2011-06-13'", 0] << ["'2011-06-14'", 0] << ["'2011-06-15'", 0] << ["'2011-06-16'", 0] << ["'2011-06-17'", 0]
|
22
|
+
expected << ["'2011-06-18'", 0] << ["'2011-06-19'", 0] << ["'2011-06-20'", 0] << ["'2011-06-21'", 0] << ["'2011-06-22'", 0]
|
23
|
+
expected << ["'2011-06-23'", 0]
|
24
|
+
|
25
|
+
assert_all(expected, result)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_yesterday_vs_today
|
29
|
+
now = Time.now.utc
|
30
|
+
y = now.yesterday
|
31
|
+
Car.create!(:created_at => now.ago(3.days))
|
32
|
+
Car.create!(:created_at => y)
|
33
|
+
Car.create!(:created_at => y)
|
34
|
+
Car.create!(:created_at => now)
|
35
|
+
result = AdminData::Analytics.daily_report(Car, now)
|
36
|
+
expected = []
|
37
|
+
expected << ["'2011-05-23'", 0] << ["'2011-05-24'", 0] << ["'2011-05-25'", 0] << ["'2011-05-26'", 0] << ["'2011-05-27'", 0]
|
38
|
+
expected << ["'2011-05-28'", 0] << ["'2011-05-29'", 0] << ["'2011-05-30'", 0] << ["'2011-05-31'", 0]
|
39
|
+
expected << ["'2011-06-01'", 0] << ["'2011-06-02'", 0]
|
40
|
+
expected << ["'2011-06-03'", 0] << ["'2011-06-04'", 0] << ["'2011-06-05'", 0] << ["'2011-06-06'", 0] << ["'2011-06-07'", 0]
|
41
|
+
expected << ["'2011-06-08'", 0] << ["'2011-06-09'", 0] << ["'2011-06-10'", 0] << ["'2011-06-11'", 0] << ["'2011-06-12'", 0]
|
42
|
+
expected << ["'2011-06-13'", 0] << ["'2011-06-14'", 0] << ["'2011-06-15'", 0] << ["'2011-06-16'", 0] << ["'2011-06-17'", 0]
|
43
|
+
expected << ["'2011-06-18'", 0] << ["'2011-06-19'", 0] << ["'2011-06-20'", 1] << ["'2011-06-21'", 0] << ["'2011-06-22'", 2]
|
44
|
+
expected << ["'2011-06-23'", 1]
|
45
|
+
|
46
|
+
assert_all(expected, result)
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def test_one_year_data_with_data_for_each_month
|
51
|
+
now = Time.now.utc
|
52
|
+
Car.create!(:created_at => now)
|
53
|
+
2.times { cc(now.ago(1.month)) }; 3.times { cc(now.ago(2.month)) }; 4.times { cc(now.ago(3.month)) }
|
54
|
+
5.times { cc(now.ago(4.month)) }; 6.times { cc(now.ago(5.month)) }; 7.times { cc(now.ago(6.month)) }
|
55
|
+
8.times { cc(now.ago(7.month)) }; 9.times { cc(now.ago(8.month)) }; 10.times { cc(now.ago(9.month)) }
|
56
|
+
11.times { cc(now.ago(10.month)) }; 12.times { cc(now.ago(11.month)) }; 13.times { cc(now.ago(12.month)) }
|
57
|
+
14.times { cc(now.ago(13.month)) }; 15.times { cc(now.ago(14.month)) };
|
58
|
+
|
59
|
+
result = AdminData::Analytics.monthly_report(Car, now)
|
60
|
+
|
61
|
+
expected = []
|
62
|
+
expected << ["'Jul-2010'", 12] << ["'Aug-2010'", 11] << ["'Sep-2010'", 10] << ["'Oct-2010'", 9]
|
63
|
+
expected << ["'Nov-2010'", 8] << ["'Dec-2010'", 7] << ["'Jan-2011'", 6] << ["'Feb-2011'", 5]
|
64
|
+
expected << ["'Mar-2011'", 4] << ["'Apr-2011'", 3] << ["'May-2011'", 2] << ["'Jun-2011'", 1]
|
65
|
+
|
66
|
+
assert_all(expected, result)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_one_year_data_with_data_missing_for_last_9_months
|
70
|
+
Car.delete_all
|
71
|
+
now = Time.now.utc
|
72
|
+
Car.create!(:created_at => now)
|
73
|
+
2.times { cc(now.ago(1.month)) }; 3.times { cc(now.ago(2.month)) };
|
74
|
+
|
75
|
+
result = AdminData::Analytics.monthly_report(Car, now)
|
76
|
+
|
77
|
+
expected = []
|
78
|
+
expected << ["'Jul-2010'", 0] << ["'Aug-2010'", 0] << ["'Sep-2010'", 0] << ["'Oct-2010'", 0]
|
79
|
+
expected << ["'Nov-2010'", 0] << ["'Dec-2010'", 0] << ["'Jan-2011'", 0] << ["'Feb-2011'", 0]
|
80
|
+
expected << ["'Mar-2011'", 0] << ["'Apr-2011'", 3] << ["'May-2011'", 2] << ["'Jun-2011'", 1]
|
81
|
+
|
82
|
+
assert_all(expected, result)
|
83
|
+
end
|
84
|
+
|
85
|
+
def assert_all(expected, result)
|
86
|
+
assert_equal expected.size, result.size
|
87
|
+
expected.each_with_index do |e, i|
|
88
|
+
assert_equal e, result[i]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def cc(time)
|
93
|
+
Car.create!(:created_at => time)
|
94
|
+
end
|
95
|
+
=end
|
96
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class UserPhoneTest < ActiveSupport::TestCase
|
4
|
+
def count_of_main_klass_records_not_in_hm_klass(main_klass, hm_klass, hm_relationship_name)
|
5
|
+
foreign_key = main_klass.reflections[hm_relationship_name].instance_variable_get('@active_record').name.foreign_key
|
6
|
+
raise 'foreign_key is nil' unless foreign_key
|
7
|
+
sql = %Q{
|
8
|
+
select count(*) as count_data
|
9
|
+
from #{main_klass.table_name}
|
10
|
+
where users.id NOT IN (
|
11
|
+
select #{hm_klass.table_name}.#{foreign_key}
|
12
|
+
from #{hm_klass.table_name}
|
13
|
+
)
|
14
|
+
}
|
15
|
+
record = main_klass.find_by_sql(sql).first
|
16
|
+
record['count_data'].to_i
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
metadata
ADDED
@@ -0,0 +1,253 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: the_jobbook_admin_data
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.0a
|
5
|
+
prerelease: 5
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Noah Chaimowicz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-11-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: will_paginate
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.1'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.1'
|
46
|
+
description: Manage data as if you own it
|
47
|
+
email:
|
48
|
+
- noah@jobbook.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- CHANGELOG.rdoc
|
55
|
+
- Gemfile
|
56
|
+
- Gemfile.lock
|
57
|
+
- Guardfile
|
58
|
+
- MIT-LICENSE
|
59
|
+
- README.md
|
60
|
+
- README.rdoc
|
61
|
+
- Rakefile
|
62
|
+
- admin_data.gemspec
|
63
|
+
- app/assets/images/add.png
|
64
|
+
- app/assets/images/admin_data/.gitkeep
|
65
|
+
- app/assets/images/no.png
|
66
|
+
- app/assets/images/site.png
|
67
|
+
- app/assets/images/sort_by_asc.jpg
|
68
|
+
- app/assets/images/sort_by_desc.jpg
|
69
|
+
- app/assets/images/sort_by_nothing.jpg
|
70
|
+
- app/assets/javascripts/admin_data.js
|
71
|
+
- app/assets/javascripts/admin_data/application.js
|
72
|
+
- app/assets/javascripts/advance_search/act_on_result.js
|
73
|
+
- app/assets/javascripts/advance_search/advance_search.js
|
74
|
+
- app/assets/javascripts/advance_search/advance_search_structure.js
|
75
|
+
- app/assets/javascripts/advance_search/ajaxify_advance_search.js
|
76
|
+
- app/assets/javascripts/advance_search/build_first_row.js
|
77
|
+
- app/assets/javascripts/advance_search/event_bindings.js
|
78
|
+
- app/assets/javascripts/advance_search/global_ajax_setting.js
|
79
|
+
- app/assets/javascripts/advance_search/sortby.js
|
80
|
+
- app/assets/javascripts/advance_search/trigger_submit_on_domready.js
|
81
|
+
- app/assets/javascripts/analytics/report.js
|
82
|
+
- app/assets/javascripts/misc/drop_down_change.js
|
83
|
+
- app/assets/javascripts/misc/js_util.js
|
84
|
+
- app/assets/javascripts/misc/quick_search_input_focus.js
|
85
|
+
- app/assets/javascripts/vendor/jquery-1.4.2.js
|
86
|
+
- app/assets/javascripts/vendor/jquery-ui-1.7.2.custom.min.js
|
87
|
+
- app/assets/javascripts/vendor/jquery.ba-isjquery.js
|
88
|
+
- app/assets/javascripts/vendor/jquery_form.js
|
89
|
+
- app/assets/javascripts/vendor/log.js
|
90
|
+
- app/assets/javascripts/vendor/rails.js
|
91
|
+
- app/assets/stylesheets/admin_data.css
|
92
|
+
- app/assets/stylesheets/admin_data/application.css
|
93
|
+
- app/assets/stylesheets/vendor/jquery-ui-1.7.2.custom.css
|
94
|
+
- app/controllers/admin_data/application_controller.rb
|
95
|
+
- app/controllers/admin_data/crud_controller.rb
|
96
|
+
- app/controllers/admin_data/feed_controller.rb
|
97
|
+
- app/controllers/admin_data/home_controller.rb
|
98
|
+
- app/controllers/admin_data/migration_controller.rb
|
99
|
+
- app/controllers/admin_data/public_controller.rb
|
100
|
+
- app/controllers/admin_data/search_controller.rb
|
101
|
+
- app/controllers/admin_data/table_structure_controller.rb
|
102
|
+
- app/helpers/admin_data/application_helper.rb
|
103
|
+
- app/views/admin_data/crud/association/_association_info.html.erb
|
104
|
+
- app/views/admin_data/crud/association/_belongs_to_info.html.erb
|
105
|
+
- app/views/admin_data/crud/association/_habtm_info.html.erb
|
106
|
+
- app/views/admin_data/crud/association/_has_many_info.html.erb
|
107
|
+
- app/views/admin_data/crud/association/_has_one_info.html.erb
|
108
|
+
- app/views/admin_data/crud/edit.html.erb
|
109
|
+
- app/views/admin_data/crud/misc/_form.html.erb
|
110
|
+
- app/views/admin_data/crud/misc/_modify_record.html.erb
|
111
|
+
- app/views/admin_data/crud/new.html.erb
|
112
|
+
- app/views/admin_data/crud/show.html.erb
|
113
|
+
- app/views/admin_data/feed/index.rss.builder
|
114
|
+
- app/views/admin_data/home/index.html.erb
|
115
|
+
- app/views/admin_data/migration/index.html.erb
|
116
|
+
- app/views/admin_data/migration/jstest.html.erb
|
117
|
+
- app/views/admin_data/search/advance_search.html.erb
|
118
|
+
- app/views/admin_data/search/quick_search.html.erb
|
119
|
+
- app/views/admin_data/search/search/_advance_search_form.html.erb
|
120
|
+
- app/views/admin_data/search/search/_errors.html.erb
|
121
|
+
- app/views/admin_data/search/search/_listing.html.erb
|
122
|
+
- app/views/admin_data/search/search/_search_form.html.erb
|
123
|
+
- app/views/admin_data/search/search/_title.html.erb
|
124
|
+
- app/views/admin_data/shared/_breadcrum.html.erb
|
125
|
+
- app/views/admin_data/shared/_drop_down_klasses.html.erb
|
126
|
+
- app/views/admin_data/shared/_flash_message.html.erb
|
127
|
+
- app/views/admin_data/shared/_header.html.erb
|
128
|
+
- app/views/admin_data/shared/_powered_by.html.erb
|
129
|
+
- app/views/admin_data/shared/_secondary_navigation.html.erb
|
130
|
+
- app/views/admin_data/table_structure/index.html.erb
|
131
|
+
- app/views/layouts/admin_data.html.erb
|
132
|
+
- app/views/layouts/admin_data/application.html.erb
|
133
|
+
- app/views/layouts/search.html.erb
|
134
|
+
- config/routes.rb
|
135
|
+
- lib/admin_data.rb
|
136
|
+
- lib/admin_data/active_record_util.rb
|
137
|
+
- lib/admin_data/analytics.rb
|
138
|
+
- lib/admin_data/authenticator.rb
|
139
|
+
- lib/admin_data/config.rb
|
140
|
+
- lib/admin_data/configuration.rb
|
141
|
+
- lib/admin_data/date_util.rb
|
142
|
+
- lib/admin_data/engine.rb
|
143
|
+
- lib/admin_data/model_finder.rb
|
144
|
+
- lib/admin_data/rails_version_check.rb
|
145
|
+
- lib/admin_data/search.rb
|
146
|
+
- lib/admin_data/setup_config.rb
|
147
|
+
- lib/admin_data/util.rb
|
148
|
+
- lib/admin_data/version.rb
|
149
|
+
- lib/tasks/admin_data_tasks.rake
|
150
|
+
- script/rails
|
151
|
+
- test/admin_data_test.rb
|
152
|
+
- test/dummy/README.md
|
153
|
+
- test/dummy/Rakefile
|
154
|
+
- test/dummy/app/controllers/application_controller.rb
|
155
|
+
- test/dummy/app/helpers/application_helper.rb
|
156
|
+
- test/dummy/app/models/user.rb
|
157
|
+
- test/dummy/app/models/user/student.rb
|
158
|
+
- test/dummy/app/views/layouts/application.html.erb
|
159
|
+
- test/dummy/config.ru
|
160
|
+
- test/dummy/config/application.rb
|
161
|
+
- test/dummy/config/boot.rb
|
162
|
+
- test/dummy/config/cucumber.yml
|
163
|
+
- test/dummy/config/database.yml
|
164
|
+
- test/dummy/config/database.yml.mysql
|
165
|
+
- test/dummy/config/database.yml.pg
|
166
|
+
- test/dummy/config/database.yml.sqlite3
|
167
|
+
- test/dummy/config/environment.rb
|
168
|
+
- test/dummy/config/environments/development.rb
|
169
|
+
- test/dummy/config/environments/production.rb
|
170
|
+
- test/dummy/config/environments/test.rb
|
171
|
+
- test/dummy/config/initializers/admin_data.rb
|
172
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
173
|
+
- test/dummy/config/initializers/empty_spaces_to_nil.rb
|
174
|
+
- test/dummy/config/initializers/inflections.rb
|
175
|
+
- test/dummy/config/initializers/mime_types.rb
|
176
|
+
- test/dummy/config/initializers/secret_token.rb
|
177
|
+
- test/dummy/config/initializers/session_store.rb
|
178
|
+
- test/dummy/config/locales/en.yml
|
179
|
+
- test/dummy/config/routes.rb
|
180
|
+
- test/dummy/db/development.sqlite3
|
181
|
+
- test/dummy/db/migrate/20091030202259_create_tables.rb
|
182
|
+
- test/dummy/db/production.sqlite3
|
183
|
+
- test/dummy/db/schema.rb
|
184
|
+
- test/dummy/db/seeds.rb
|
185
|
+
- test/dummy/db/test.sqlite3
|
186
|
+
- test/dummy/features/advance_search/boolean.feature
|
187
|
+
- test/dummy/features/advance_search/datetime.feature
|
188
|
+
- test/dummy/features/advance_search/delete_all.feature
|
189
|
+
- test/dummy/features/advance_search/destroy_all.feature
|
190
|
+
- test/dummy/features/advance_search/integer.feature
|
191
|
+
- test/dummy/features/advance_search/multiple_rows.feature
|
192
|
+
- test/dummy/features/advance_search/string.feature
|
193
|
+
- test/dummy/features/crud.feature
|
194
|
+
- test/dummy/features/crud_show.feature
|
195
|
+
- test/dummy/features/feed.feature
|
196
|
+
- test/dummy/features/home.feature
|
197
|
+
- test/dummy/features/migration.feature
|
198
|
+
- test/dummy/features/quick_search.feature
|
199
|
+
- test/dummy/features/step_definitions/advance_search_steps.rb
|
200
|
+
- test/dummy/features/step_definitions/app_steps.rb
|
201
|
+
- test/dummy/features/step_definitions/async.rb
|
202
|
+
- test/dummy/features/step_definitions/configuration_steps.rb
|
203
|
+
- test/dummy/features/step_definitions/crud_show_steps.rb
|
204
|
+
- test/dummy/features/step_definitions/feed_steps.rb
|
205
|
+
- test/dummy/features/step_definitions/quick_search_steps.rb
|
206
|
+
- test/dummy/features/step_definitions/util.rb
|
207
|
+
- test/dummy/features/step_definitions/web_steps.rb
|
208
|
+
- test/dummy/features/support/env.rb
|
209
|
+
- test/dummy/features/support/hooks.rb
|
210
|
+
- test/dummy/features/support/paths.rb
|
211
|
+
- test/dummy/features/table_structure.feature
|
212
|
+
- test/dummy/lib/tasks/.gitkeep
|
213
|
+
- test/dummy/lib/tasks/cucumber.rake
|
214
|
+
- test/dummy/lib/tasks/dbs.rake
|
215
|
+
- test/dummy/lib/tasks/sample_cars.rake
|
216
|
+
- test/dummy/public/.gitkeep
|
217
|
+
- test/dummy/script/cucumber
|
218
|
+
- test/dummy/script/rails
|
219
|
+
- test/dummy/test/factories.rb
|
220
|
+
- test/dummy/test/test_helper.rb
|
221
|
+
- test/integration/navigation_test.rb
|
222
|
+
- test/test_helper.rb
|
223
|
+
- test/unit/admin_data/model_finder_test.rb
|
224
|
+
- test/unit/car_test.rb
|
225
|
+
- test/unit/user_phone_test.rb
|
226
|
+
homepage: ''
|
227
|
+
licenses: []
|
228
|
+
post_install_message:
|
229
|
+
rdoc_options: []
|
230
|
+
require_paths:
|
231
|
+
- lib
|
232
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
233
|
+
none: false
|
234
|
+
requirements:
|
235
|
+
- - ! '>='
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0'
|
238
|
+
segments:
|
239
|
+
- 0
|
240
|
+
hash: 4595131214372577890
|
241
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
242
|
+
none: false
|
243
|
+
requirements:
|
244
|
+
- - ! '>'
|
245
|
+
- !ruby/object:Gem::Version
|
246
|
+
version: 1.3.1
|
247
|
+
requirements: []
|
248
|
+
rubyforge_project: thejobbook_admin_data
|
249
|
+
rubygems_version: 1.8.23
|
250
|
+
signing_key:
|
251
|
+
specification_version: 3
|
252
|
+
summary: Manage data as if you own it
|
253
|
+
test_files: []
|