admin_data 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +221 -0
- data/README.textile +21 -0
- data/Rakefile +46 -0
- data/app/controllers/admin_data/base_controller.rb +114 -0
- data/app/controllers/admin_data/diagnostic_controller.rb +28 -0
- data/app/controllers/admin_data/feed_controller.rb +17 -0
- data/app/controllers/admin_data/main_controller.rb +132 -0
- data/app/controllers/admin_data/migration_controller.rb +19 -0
- data/app/controllers/admin_data/search_controller.rb +125 -0
- data/app/controllers/admin_data/validate_model_controller.rb +106 -0
- data/app/views/admin_data/diagnostic/index.html.erb +17 -0
- data/app/views/admin_data/diagnostic/missing_index.html.erb +26 -0
- data/app/views/admin_data/feed/index.rss.builder +24 -0
- data/app/views/admin_data/main/all_models.html.erb +22 -0
- data/app/views/admin_data/main/association/_association_info.html.erb +10 -0
- data/app/views/admin_data/main/association/_belongs_to_info.html.erb +7 -0
- data/app/views/admin_data/main/association/_has_many_info.html.erb +7 -0
- data/app/views/admin_data/main/association/_has_one_info.html.erb +6 -0
- data/app/views/admin_data/main/edit.html.erb +38 -0
- data/app/views/admin_data/main/misc/_form.html.erb +25 -0
- data/app/views/admin_data/main/misc/_modify_record.html.erb +22 -0
- data/app/views/admin_data/main/new.html.erb +23 -0
- data/app/views/admin_data/main/show.html.erb +41 -0
- data/app/views/admin_data/main/table_structure.html.erb +55 -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/_search_base.html.erb +34 -0
- data/app/views/admin_data/search/advance_search.html.erb +3 -0
- data/app/views/admin_data/search/quick_search.html.erb +6 -0
- data/app/views/admin_data/search/search/_advance_search_form.html.erb +48 -0
- data/app/views/admin_data/search/search/_errors.html.erb +5 -0
- data/app/views/admin_data/search/search/_listing.html.erb +40 -0
- data/app/views/admin_data/search/search/_search_form.html.erb +28 -0
- data/app/views/admin_data/search/search/_sortby.html.erb +18 -0
- data/app/views/admin_data/search/search/_title.html.erb +34 -0
- data/app/views/admin_data/shared/_breadcrum.html.erb +10 -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 +23 -0
- data/app/views/admin_data/shared/_powered_by.html.erb +23 -0
- data/app/views/admin_data/shared/_secondary_navigation.html.erb +28 -0
- data/app/views/admin_data/validate_model/_bad.html.erb +1 -0
- data/app/views/admin_data/validate_model/tid.html.erb +2 -0
- data/app/views/admin_data/validate_model/validate.html.erb +67 -0
- data/app/views/layouts/admin_data.html.erb +60 -0
- data/config/routes.rb +34 -0
- data/init.rb +1 -0
- data/lib/admin_data.rb +34 -0
- data/lib/admin_data/chelper.rb +37 -0
- data/lib/admin_data/compatibility.rb +7 -0
- data/lib/admin_data/helpers.rb +222 -0
- data/lib/admin_data/railtie.rb +21 -0
- data/lib/admin_data/search.rb +186 -0
- data/lib/admin_data/settings.rb +72 -0
- data/lib/admin_data/util.rb +237 -0
- data/lib/admin_data/version.rb +3 -0
- data/lib/admin_data_date_validation.rb +79 -0
- data/lib/css/app.css +224 -0
- data/lib/css/base.css +1071 -0
- data/lib/css/header.css +65 -0
- data/lib/css/rounded.css +18 -0
- data/lib/css/themes/drastic-dark/style.css +374 -0
- data/lib/css/umbrella.css +34 -0
- data/lib/css/vendor/images/ui-bg_diagonals-thick_75_f3d8d8_40x40.png +0 -0
- data/lib/css/vendor/images/ui-bg_dots-small_65_a6a6a6_2x2.png +0 -0
- data/lib/css/vendor/images/ui-bg_flat_0_333333_40x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_flat_65_ffffff_40x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_glass_55_fbf8ee_1x400.png +0 -0
- data/lib/css/vendor/images/ui-bg_highlight-hard_100_eeeeee_1x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_highlight-hard_100_f6f6f6_1x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_highlight-soft_15_cc0000_1x100.png +0 -0
- data/lib/css/vendor/images/ui-icons_004276_256x240.png +0 -0
- data/lib/css/vendor/images/ui-icons_cc0000_256x240.png +0 -0
- data/lib/css/vendor/images/ui-icons_ffffff_256x240.png +0 -0
- data/lib/css/vendor/jquery-ui-1.7.2.custom.css +406 -0
- data/lib/css/vendor/qunit.css +119 -0
- data/lib/js/advance_search/act_on_result.js +47 -0
- data/lib/js/advance_search/adv_search.js +46 -0
- data/lib/js/advance_search/advance_search.js +60 -0
- data/lib/js/advance_search/advance_search_structure.js +79 -0
- data/lib/js/advance_search/ajaxify_advance_search.js +28 -0
- data/lib/js/advance_search/build_first_row.js +12 -0
- data/lib/js/advance_search/event_bindings.js +87 -0
- data/lib/js/advance_search/global_ajax_setting.js +10 -0
- data/lib/js/advance_search/trigger_submit_on_domready.js +6 -0
- data/lib/js/misc/drop_down_change.js +8 -0
- data/lib/js/misc/js_util.js +42 -0
- data/lib/js/misc/quick_search_input_focus.js +6 -0
- data/lib/js/test/act_on_result.js +120 -0
- data/lib/js/test/advance_search.js +80 -0
- data/lib/js/test/ajaxify_advance_search.js +29 -0
- data/lib/js/test/build_first_row.js +10 -0
- data/lib/js/test/event_bindings.js +100 -0
- data/lib/js/validate_model/ajaxify_form.js +66 -0
- data/lib/js/validate_model/select_all.js +15 -0
- data/lib/js/vendor/jack.js +903 -0
- data/lib/js/vendor/jquery-1.4.1.js +6078 -0
- data/lib/js/vendor/jquery-ui-1.7.2.custom.min.js +298 -0
- data/lib/js/vendor/jquery.ba-isjquery.js +21 -0
- data/lib/js/vendor/jquery.form.js +814 -0
- data/lib/js/vendor/jquery.lint.js +604 -0
- data/lib/js/vendor/log.js +9 -0
- data/lib/js/vendor/qunit.js +1043 -0
- data/lib/tasks/admin_data_tasks.rake +7 -0
- data/lib/tasks/validate_models_bg.rake +23 -0
- data/test/factories/article.rb +9 -0
- data/test/factories/car.rb +4 -0
- data/test/factories/city.rb +4 -0
- data/test/factories/comment.rb +6 -0
- data/test/factories/door.rb +4 -0
- data/test/factories/engine.rb +4 -0
- data/test/functional/base_controller_test.rb +5 -0
- data/test/functional/feed_controller_test.rb +34 -0
- data/test/functional/main_controller_test.rb +421 -0
- data/test/functional/migration_controller_test.rb +30 -0
- data/test/functional/routes_test.rb +61 -0
- data/test/functional/search_controller_test.rb +814 -0
- data/test/helper/view_helper_test.rb +177 -0
- data/test/misc_tests/date_validation_test.rb +32 -0
- data/test/misc_tests/settings_test.rb +29 -0
- data/test/misc_tests/util_test.rb +83 -0
- data/test/rails_root/Gemfile +22 -0
- data/test/rails_root/Gemfile.lock +101 -0
- data/test/rails_root/Rakefile +7 -0
- data/test/rails_root/app/controllers/application_controller.rb +3 -0
- data/test/rails_root/app/helpers/application_helper.rb +2 -0
- data/test/rails_root/app/models/article.rb +25 -0
- data/test/rails_root/app/models/city.rb +15 -0
- data/test/rails_root/app/models/comment.rb +13 -0
- data/test/rails_root/app/models/tech_magazine.rb +2 -0
- data/test/rails_root/app/models/vehicle/car.rb +4 -0
- data/test/rails_root/app/models/vehicle/door.rb +3 -0
- data/test/rails_root/app/models/vehicle/engine.rb +3 -0
- data/test/rails_root/app/views/layouts/application.html.erb +14 -0
- data/test/rails_root/config.ru +4 -0
- data/test/rails_root/config/application.rb +42 -0
- data/test/rails_root/config/boot.rb +13 -0
- data/test/rails_root/config/database.yml +22 -0
- data/test/rails_root/config/environment.rb +5 -0
- data/test/rails_root/config/environments/development.rb +22 -0
- data/test/rails_root/config/environments/production.rb +49 -0
- data/test/rails_root/config/environments/test.rb +35 -0
- data/test/rails_root/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_root/config/initializers/inflections.rb +10 -0
- data/test/rails_root/config/initializers/mime_types.rb +5 -0
- data/test/rails_root/config/initializers/secret_token.rb +7 -0
- data/test/rails_root/config/initializers/session_store.rb +8 -0
- data/test/rails_root/config/locales/en.yml +5 -0
- data/test/rails_root/config/routes.rb +58 -0
- data/test/rails_root/db/migrate/20090809061114_create_tables.rb +70 -0
- data/test/rails_root/db/schema.rb +74 -0
- data/test/rails_root/db/seeds.rb +7 -0
- data/test/rails_root/script/rails +6 -0
- data/test/rails_root/test/performance/browsing_test.rb +0 -0
- data/test/rails_root/test/test_helper.rb +13 -0
- data/test/support/assertions.rb +20 -0
- data/test/test_helper.rb +74 -0
- metadata +321 -0
@@ -0,0 +1,177 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ViewHelperTest < ActionView::TestCase
|
4
|
+
|
5
|
+
include FlexMock::TestCase
|
6
|
+
|
7
|
+
self.helper_class = AdminData::Helpers
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@f = flexmock
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'admin_data_form_field_id' do
|
14
|
+
context 'for primary key article_id' do
|
15
|
+
setup do
|
16
|
+
article = Factory(:article)
|
17
|
+
col = Article.columns.detect {|col| col.name == 'article_id'}
|
18
|
+
@output = admin_data_form_field(Article, article, col, @f)
|
19
|
+
end
|
20
|
+
should 'have value auto for id' do
|
21
|
+
assert_equal "(auto)", @output
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'for primary key id' do
|
26
|
+
setup do
|
27
|
+
comment = Factory(:comment)
|
28
|
+
col = Comment.columns.detect {|col| col.name == 'id'}
|
29
|
+
@output = admin_data_form_field(Comment, comment, col, @f)
|
30
|
+
end
|
31
|
+
should 'have value auto for id' do
|
32
|
+
assert_equal "(auto)", @output
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'for text_field' do
|
37
|
+
setup do
|
38
|
+
article = Factory(:article)
|
39
|
+
col = Article.columns.detect {|col| col.name == 'hits_count'}
|
40
|
+
@expected = '<input> for hits_count'
|
41
|
+
@f.should_receive(:text_field).with('hits_count', {:class => "nice-field", :size => 60}).and_return(@expected)
|
42
|
+
@output = admin_data_form_field(Article, article, col, @f)
|
43
|
+
end
|
44
|
+
should 'have input text' do
|
45
|
+
assert_equal @expected, @output
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'for datetime_select' do
|
51
|
+
setup do
|
52
|
+
col = Article.columns_hash['published_at']
|
53
|
+
@article = Factory(:article, :published_at => Time.parse('Aug 31, 1999 1:23:45'))
|
54
|
+
initial_dropdowns = '<input type="hidden">for year and <select>s for month and day and <select>s for time'
|
55
|
+
@expected_html = '<input type="text" size="4" class="nice-field">for year and <select>s for month and day and <select>s for time'
|
56
|
+
flexmock(self).should_receive(:params).and_return({:action => 'edit'})
|
57
|
+
@f.should_receive(:datetime_select).with('published_at', {:include_blank => true}).and_return(initial_dropdowns)
|
58
|
+
@output = admin_data_form_field(Article, @article, col, @f)
|
59
|
+
end
|
60
|
+
should 'have expected output' do
|
61
|
+
assert_equal @expected_html, @output
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'for date_select' do
|
66
|
+
setup do
|
67
|
+
col = Article.columns_hash['published_at']
|
68
|
+
flexmock(col).should_receive(:type).and_return(:date)
|
69
|
+
@article = Factory(:article, :published_at => Date.parse('Aug 31, 1999'))
|
70
|
+
initial_dropdowns = '<input type="hidden">for year and <select>s for month and day'
|
71
|
+
@expected_html = '<input type="text" size="4" class="nice-field">for year and <select>s for month and day'
|
72
|
+
flexmock(self).should_receive(:params).and_return({:action => 'edit'})
|
73
|
+
@f.should_receive(:date_select).with('published_at', {:discard_year => true, :include_blank => true}).and_return(initial_dropdowns)
|
74
|
+
@output = admin_data_form_field(Article, @article, col, @f)
|
75
|
+
end
|
76
|
+
should 'have expected value' do
|
77
|
+
assert_equal @expected_html, @output
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'for collection_select' do
|
82
|
+
setup do
|
83
|
+
@article = Factory(:article)
|
84
|
+
@comment = Factory(:comment, :article => @article)
|
85
|
+
col = Comment.columns.detect {|col| col.name == 'article_id'}
|
86
|
+
@expected = '<select> for articles'
|
87
|
+
all_articles = flexmock
|
88
|
+
flexmock(Article).should_receive(:all).with(:order => "article_id asc").and_return(all_articles)
|
89
|
+
@f.should_receive(:collection_select).with('article_id', all_articles, :id, 'article_id', {:include_blank => true} ).and_return(@expected)
|
90
|
+
@output = admin_data_form_field(Comment, @comment, col, @f)
|
91
|
+
end
|
92
|
+
should 'have expected value' do
|
93
|
+
assert_equal @expected, @output
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'invoke admin_data_get_value_for_column' do
|
98
|
+
context 'for text column' do
|
99
|
+
context 'untrucated case' do
|
100
|
+
setup do
|
101
|
+
column = Article.columns.select {|column| column.name.to_s == 'title'}.first
|
102
|
+
@article = Factory(:article)
|
103
|
+
@output = admin_data_get_value_for_column(column, @article, {})
|
104
|
+
end
|
105
|
+
should 'have untruncated title' do
|
106
|
+
assert_equal 'this is a dummy title', @output
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'truncated case' do
|
111
|
+
setup do
|
112
|
+
column = Article.columns.select {|column| column.name.to_s == 'title'}.first
|
113
|
+
@article = Factory(:article, :title => 'this is a very very very long long long title')
|
114
|
+
options = {}
|
115
|
+
|
116
|
+
@output = admin_data_get_value_for_column(column,@article,{:limit => 15})
|
117
|
+
end
|
118
|
+
should 'should have truncated title' do
|
119
|
+
assert_equal 'this is a ve...', @output
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'for integer column' do
|
125
|
+
setup do
|
126
|
+
@article = Factory(:article, :hits_count => 100)
|
127
|
+
column = Article.columns.select {|column| column.name.to_s == 'hits_count'}.first
|
128
|
+
@output = admin_data_get_value_for_column(column, @article)
|
129
|
+
end
|
130
|
+
should 'have right value' do
|
131
|
+
assert_equal 100, @output
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'for integer column with truncate option should not cause any problem' do
|
136
|
+
setup do
|
137
|
+
@article = Factory(:article, :hits_count => 100)
|
138
|
+
column = Article.columns.select {|column| column.name.to_s == 'hits_count'}.first
|
139
|
+
@output = admin_data_get_value_for_column(column, @article, {:limit => 10})
|
140
|
+
end
|
141
|
+
should 'have right value' do
|
142
|
+
assert_equal 100, @output
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'for text column which should raise exception' do
|
147
|
+
setup do
|
148
|
+
column = Article.columns.select {|column| column.name.to_s == 'title'}.first
|
149
|
+
@article = Factory(:article, :title => 'this is a very very very long long long title')
|
150
|
+
options = {}
|
151
|
+
|
152
|
+
#truncate method should raise exception
|
153
|
+
flexmock(self).should_receive('truncate').with('any_args').and_raise(Exception)
|
154
|
+
|
155
|
+
@output = admin_data_get_value_for_column(column,@article,{:limit => 15})
|
156
|
+
end
|
157
|
+
should 'have rescued message' do
|
158
|
+
assert_equal '<actual data is not being shown because truncate method failed.>', @output
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'for text column which is serialized' do
|
163
|
+
setup do
|
164
|
+
column = Article.columns.select {|column| column.name.to_s == 'data'}.first
|
165
|
+
@article = Factory(:article, :data => { :key => 123456789 }.to_yaml)
|
166
|
+
options = {}
|
167
|
+
|
168
|
+
@output = admin_data_get_value_for_column(column,@article,{:limit => 15})
|
169
|
+
end
|
170
|
+
should 'show inspected value' do
|
171
|
+
assert_equal "{:key=>12345...", @output
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'admin_data_date_validation'
|
3
|
+
|
4
|
+
class AdminDataTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_date_validation
|
7
|
+
|
8
|
+
assert ::AdminDataDateValidation.validate('13-feb-2009')
|
9
|
+
assert ::AdminDataDateValidation.validate('13-FEB-2009')
|
10
|
+
assert ::AdminDataDateValidation.validate('13-feb -2009') # extra white space should not hurt
|
11
|
+
|
12
|
+
# only the first three characters of the month should be checked
|
13
|
+
assert ::AdminDataDateValidation.validate('13-FEBfoo-2009')
|
14
|
+
|
15
|
+
assert !::AdminDataDateValidation.validate('13-foo-2009') # month name is wrong
|
16
|
+
assert !::AdminDataDateValidation.validate('13 foo 2009') # there must be two occurences of -
|
17
|
+
assert !::AdminDataDateValidation.validate('32-jan-2009') # day is wrong
|
18
|
+
assert !::AdminDataDateValidation.validate('32-jan- -2009') # there should be only two occurences of -
|
19
|
+
assert !::AdminDataDateValidation.validate('32-jan-09') # year must be greater than 1900
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_date_validation_with_operator
|
23
|
+
assert ::AdminDataDateValidation.validate_with_operator('> 13-feb-2009')
|
24
|
+
assert ::AdminDataDateValidation.validate_with_operator('>= 13-feb-2009')
|
25
|
+
assert ::AdminDataDateValidation.validate_with_operator('< 13-feb-2009')
|
26
|
+
assert ::AdminDataDateValidation.validate_with_operator('<= 13-feb-2009')
|
27
|
+
|
28
|
+
assert !::AdminDataDateValidation.validate_with_operator('<=13-feb-2009') # no white space
|
29
|
+
assert !::AdminDataDateValidation.validate_with_operator('| 13-feb-2009') # invalid operator
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class AdminData::AdminDataConfigTest < ActionController::TestCase
|
4
|
+
context 'setting configuration parameters' do
|
5
|
+
teardown do
|
6
|
+
AdminData::Config.initialize_defaults
|
7
|
+
end
|
8
|
+
|
9
|
+
%w(
|
10
|
+
find_conditions
|
11
|
+
plugin_dir
|
12
|
+
will_paginate_per_page
|
13
|
+
is_allowed_to_view
|
14
|
+
is_allowed_to_update
|
15
|
+
).each do |valid_key|
|
16
|
+
should "store #{valid_key} setting" do
|
17
|
+
AdminData::Config.set = { valid_key.to_sym => "some value for #{valid_key}" }
|
18
|
+
assert_equal "some value for #{valid_key}", AdminData::Config.setting[valid_key.to_sym]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "get an error with a bad key" do
|
23
|
+
should "raise error when attempting to set bad key" do
|
24
|
+
assert_raises(RuntimeError) { AdminData::Config.set = { :a_bad_key => "some value" }}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'admin_data/util'
|
3
|
+
|
4
|
+
class AdminDataUtilTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
context 'has_one' do
|
7
|
+
subject { AdminData::Util.has_one_what(Vehicle::Car) }
|
8
|
+
setup { @instance = Vehicle::Car.create(:year => 2000, :brand => 'bmw') }
|
9
|
+
should 'be engine' do
|
10
|
+
assert subject
|
11
|
+
assert_equal 1, subject.size
|
12
|
+
assert_equal 'engine', subject[0]
|
13
|
+
end
|
14
|
+
should 'respond_to? has_one' do
|
15
|
+
assert @instance.respond_to?(subject[0])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'columns_order default order' do
|
20
|
+
setup do
|
21
|
+
AdminData::Config.set = {:columns_order => nil }
|
22
|
+
@output = AdminData::Util.columns_order('Article')
|
23
|
+
end
|
24
|
+
should 'have created_at and updated_at at the very end' do
|
25
|
+
assert_equal %w(article_id title body body_html short_desc status published_at approved hits_count
|
26
|
+
magazine_type magazine_id data created_at updated_at
|
27
|
+
), @output
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'columns_order custom order' do
|
32
|
+
setup do
|
33
|
+
AdminData::Config.set = {:columns_order => {'Article' => [:article_id, :body, :published_at] }}
|
34
|
+
@output = AdminData::Util.columns_order('Article')
|
35
|
+
end
|
36
|
+
should 'have right order' do
|
37
|
+
assert_equal %w(article_id body published_at title body_html short_desc status approved hits_count
|
38
|
+
magazine_type created_at updated_at magazine_id data
|
39
|
+
),
|
40
|
+
@output
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'oracle test' do
|
45
|
+
setup do
|
46
|
+
AdminData::Config.setting.merge!(:adapter_name => 'Oracle')
|
47
|
+
@term = Search::Term.new(Article,{:col1 => 'body_html', :col2 => 'contains', :col3 => 'foo'}, 'quick_search')
|
48
|
+
end
|
49
|
+
teardown do
|
50
|
+
AdminData::Config.setting.merge!(:adapter => 'MySQL')
|
51
|
+
end
|
52
|
+
should 'have proper sql' do
|
53
|
+
assert_equal ["upper(articles.body_html) LIKE ?", "%FOO%"], @term.attribute_condition
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'postgresql test' do
|
58
|
+
setup do
|
59
|
+
AdminData::Config.setting.merge!(:adapter_name => 'PostgreSql')
|
60
|
+
@term = Search::Term.new(Article,{:col1 => 'body_html', :col2 => 'contains', :col3 => 'foo'}, 'quick_search')
|
61
|
+
end
|
62
|
+
teardown do
|
63
|
+
AdminData::Config.setting.merge!(:adapter => 'MySQL')
|
64
|
+
end
|
65
|
+
should 'have proper sql' do
|
66
|
+
assert_equal ["articles.body_html ILIKE ?", "%foo%"], @term.attribute_condition
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'mysql test' do
|
71
|
+
setup do
|
72
|
+
AdminData::Config.setting.merge!(:adapter_name => 'MySQL')
|
73
|
+
@term = Search::Term.new(Article,{:col1 => 'body_html', :col2 => 'contains', :col3 => 'foo'}, 'quick_search')
|
74
|
+
end
|
75
|
+
teardown do
|
76
|
+
AdminData::Config.setting.merge!(:adapter => 'MySQL')
|
77
|
+
end
|
78
|
+
should 'have proper sql' do
|
79
|
+
assert_equal ["articles.body_html LIKE ?", "%foo%"], @term.attribute_condition
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '3.0.0.rc'
|
4
|
+
|
5
|
+
# Bundle edge Rails instead:
|
6
|
+
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
7
|
+
|
8
|
+
gem 'sqlite3-ruby', :require => 'sqlite3'
|
9
|
+
|
10
|
+
gem 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git', :branch => 'rails3'
|
11
|
+
|
12
|
+
# Bundle gems for the local environment. Make sure to
|
13
|
+
# put test-only gems in this group so their generators
|
14
|
+
# and rake tasks are available in development mode:
|
15
|
+
group :development, :test do
|
16
|
+
gem 'shoulda'
|
17
|
+
gem 'factory_girl_rails', :git => 'git://github.com/thoughtbot/factory_girl_rails'
|
18
|
+
gem 'flexmock'
|
19
|
+
gem 'redgreen'
|
20
|
+
gem 'nokogiri'
|
21
|
+
gem 'json'
|
22
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/mislav/will_paginate.git
|
3
|
+
revision: 3615938
|
4
|
+
branch: rails3
|
5
|
+
specs:
|
6
|
+
will_paginate (3.0.pre2)
|
7
|
+
|
8
|
+
GIT
|
9
|
+
remote: git://github.com/thoughtbot/factory_girl_rails
|
10
|
+
revision: 338105c
|
11
|
+
specs:
|
12
|
+
factory_girl_rails (1.0)
|
13
|
+
factory_girl (~> 1.3)
|
14
|
+
rails (>= 3.0.0.beta4)
|
15
|
+
|
16
|
+
GEM
|
17
|
+
remote: http://rubygems.org/
|
18
|
+
specs:
|
19
|
+
abstract (1.0.0)
|
20
|
+
actionmailer (3.0.0.rc)
|
21
|
+
actionpack (= 3.0.0.rc)
|
22
|
+
mail (~> 2.2.5)
|
23
|
+
actionpack (3.0.0.rc)
|
24
|
+
activemodel (= 3.0.0.rc)
|
25
|
+
activesupport (= 3.0.0.rc)
|
26
|
+
builder (~> 2.1.2)
|
27
|
+
erubis (~> 2.6.6)
|
28
|
+
i18n (~> 0.4.1)
|
29
|
+
rack (~> 1.2.1)
|
30
|
+
rack-mount (~> 0.6.9)
|
31
|
+
rack-test (~> 0.5.4)
|
32
|
+
tzinfo (~> 0.3.22)
|
33
|
+
activemodel (3.0.0.rc)
|
34
|
+
activesupport (= 3.0.0.rc)
|
35
|
+
builder (~> 2.1.2)
|
36
|
+
i18n (~> 0.4.1)
|
37
|
+
activerecord (3.0.0.rc)
|
38
|
+
activemodel (= 3.0.0.rc)
|
39
|
+
activesupport (= 3.0.0.rc)
|
40
|
+
arel (~> 0.4.0)
|
41
|
+
tzinfo (~> 0.3.22)
|
42
|
+
activeresource (3.0.0.rc)
|
43
|
+
activemodel (= 3.0.0.rc)
|
44
|
+
activesupport (= 3.0.0.rc)
|
45
|
+
activesupport (3.0.0.rc)
|
46
|
+
arel (0.4.0)
|
47
|
+
activesupport (>= 3.0.0.beta)
|
48
|
+
builder (2.1.2)
|
49
|
+
erubis (2.6.6)
|
50
|
+
abstract (>= 1.0.0)
|
51
|
+
factory_girl (1.3.2)
|
52
|
+
flexmock (0.8.7)
|
53
|
+
i18n (0.4.1)
|
54
|
+
json (1.4.6)
|
55
|
+
mail (2.2.5)
|
56
|
+
activesupport (>= 2.3.6)
|
57
|
+
mime-types
|
58
|
+
treetop (>= 1.4.5)
|
59
|
+
mime-types (1.16)
|
60
|
+
nokogiri (1.4.3.1)
|
61
|
+
polyglot (0.3.1)
|
62
|
+
rack (1.2.1)
|
63
|
+
rack-mount (0.6.9)
|
64
|
+
rack (>= 1.0.0)
|
65
|
+
rack-test (0.5.4)
|
66
|
+
rack (>= 1.0)
|
67
|
+
rails (3.0.0.rc)
|
68
|
+
actionmailer (= 3.0.0.rc)
|
69
|
+
actionpack (= 3.0.0.rc)
|
70
|
+
activerecord (= 3.0.0.rc)
|
71
|
+
activeresource (= 3.0.0.rc)
|
72
|
+
activesupport (= 3.0.0.rc)
|
73
|
+
bundler (>= 1.0.0.rc.1)
|
74
|
+
railties (= 3.0.0.rc)
|
75
|
+
railties (3.0.0.rc)
|
76
|
+
actionpack (= 3.0.0.rc)
|
77
|
+
activesupport (= 3.0.0.rc)
|
78
|
+
rake (>= 0.8.3)
|
79
|
+
thor (~> 0.14.0)
|
80
|
+
rake (0.8.7)
|
81
|
+
redgreen (1.2.2)
|
82
|
+
shoulda (2.11.3)
|
83
|
+
sqlite3-ruby (1.3.1)
|
84
|
+
thor (0.14.0)
|
85
|
+
treetop (1.4.8)
|
86
|
+
polyglot (>= 0.3.1)
|
87
|
+
tzinfo (0.3.22)
|
88
|
+
|
89
|
+
PLATFORMS
|
90
|
+
ruby
|
91
|
+
|
92
|
+
DEPENDENCIES
|
93
|
+
factory_girl_rails!
|
94
|
+
flexmock
|
95
|
+
json
|
96
|
+
nokogiri
|
97
|
+
rails (= 3.0.0.rc)
|
98
|
+
redgreen
|
99
|
+
shoulda
|
100
|
+
sqlite3-ruby
|
101
|
+
will_paginate!
|