parlement 0.14 → 0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +41 -1
- data/MEMORY +66 -5
- data/README +10 -5
- data/Rakefile +15 -23
- data/app/controllers/account_controller.rb +48 -43
- data/app/controllers/{application.rb → application_controller.rb} +15 -12
- data/app/controllers/elt_controller.rb +77 -32
- data/app/controllers/subscriber_controller.rb +11 -10
- data/app/helpers/application_helper.rb +14 -1
- data/app/helpers/elt_helper.rb +9 -7
- data/app/models/elt.rb +25 -24
- data/app/models/mail.rb +44 -47
- data/app/models/person_notify.rb +2 -2
- data/app/models/user.rb +128 -2
- data/app/models/user_notify.rb +15 -15
- data/app/views/account/_login.rhtml +39 -39
- data/app/views/account/_show.rhtml +22 -30
- data/app/views/account/signup.rhtml +2 -2
- data/app/views/elt/_choice.rhtml +6 -6
- data/app/views/elt/_elt.rhtml +27 -32
- data/app/views/elt/choices.rhtml +16 -18
- data/app/views/elt/list/_byDate.rhtml +14 -14
- data/app/views/elt/list/_byVote.rhtml +15 -15
- data/app/views/elt/list/_children.rhtml +48 -40
- data/app/views/elt/list/_subscribers.rhtml +1 -1
- data/app/views/elt/new.rhtml +22 -21
- data/app/views/elt/rss.rxml +4 -11
- data/app/views/elt/show.rhtml +65 -61
- data/app/views/elt/vote_rss.rxml +4 -11
- data/app/views/layouts/top.rhtml +39 -50
- data/app/views/person/_listElts.rhtml +1 -1
- data/app/views/person/show.rhtml +1 -1
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/change_password.rhtml +0 -0
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/delete.rhtml +0 -0
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/forgot_password.rhtml +0 -0
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/pending_delete.rhtml +0 -0
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/signup.rhtml +0 -0
- data/config/boot.rb +97 -32
- data/config/environment.rb +37 -35
- data/config/environments/development.rb +2 -3
- data/config/environments/production.rb +3 -0
- data/config/initializers/string_ruby_1.8.rb +10 -0
- data/config/routes.rb +17 -22
- data/db/schema.rb +102 -74
- data/lib/tasks/rspec.rake +167 -0
- data/public/404.html +25 -7
- data/public/500.html +26 -7
- data/public/dispatch.cgi +0 -0
- data/public/dispatch.fcgi +0 -0
- data/public/dispatch.rb +0 -0
- data/public/images/live_tree_branch_collapsed_icon.gif +0 -0
- data/public/images/live_tree_branch_expanded_icon.gif +0 -0
- data/public/images/live_tree_leaf_icon.gif +0 -0
- data/public/javascripts/application.js +258 -0
- data/public/javascripts/controls.js +544 -414
- data/public/javascripts/dragdrop.js +229 -198
- data/public/javascripts/effects.js +499 -459
- data/public/javascripts/prototype.js +2926 -1121
- data/public/javascripts/shadedborder.js +68 -50
- data/public/stylesheets/default.css +34 -34
- data/public/stylesheets/live_tree.css +0 -0
- data/public/stylesheets/scaffold.css +6 -6
- data/script/about +0 -0
- data/script/autospec +6 -0
- data/script/benchmarker +0 -0
- data/script/breakpointer +0 -0
- data/script/console +0 -0
- data/script/dbconsole +3 -0
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/script/plugin +0 -0
- data/script/profiler +0 -0
- data/script/runner +0 -0
- data/script/server +0 -0
- data/script/spec +10 -0
- data/script/spec_server +9 -0
- data/test/unit/attachment_test.rb +4 -4
- data/test/unit/choice_test.rb +1 -1
- data/test/unit/elt_test.rb +9 -9
- data/test/unit/mail_notify_test.rb +2 -2
- data/test/unit/mail_test.rb +18 -11
- data/test/unit/person_notify_test.rb +1 -1
- data/test/unit/person_test.rb +1 -1
- data/test/unit/subscriber_test.rb +1 -1
- data/test/unit/user_test.rb +81 -0
- data/test/unit/visit_test.rb +6 -6
- data/vendor/plugins/activerecord_foreign_key_extensions/init.rb +2 -0
- data/vendor/plugins/activerecord_foreign_key_extensions/lib/active_record_extensions.rb +182 -0
- data/vendor/plugins/activerecord_text_id_extensions/init.rb +2 -0
- data/vendor/plugins/activerecord_text_id_extensions/lib/active_record_extensions.rb +24 -0
- data/vendor/plugins/acts_as_nested_set/README +15 -0
- data/vendor/plugins/acts_as_nested_set/init.rb +1 -0
- data/vendor/plugins/acts_as_nested_set/lib/active_record/acts/nested_set.rb +210 -0
- data/vendor/plugins/acts_as_nested_set/test/nested_set_test.rb +269 -0
- data/vendor/plugins/acts_as_tree/README +26 -0
- data/vendor/plugins/acts_as_tree/Rakefile +22 -0
- data/vendor/plugins/acts_as_tree/init.rb +1 -0
- data/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb +96 -0
- data/vendor/plugins/{output_compression/CHANGELOG → acts_as_tree/test/abstract_unit.rb} +0 -0
- data/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb +219 -0
- data/vendor/plugins/acts_as_tree/test/database.yml +0 -0
- data/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb +0 -0
- data/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml +0 -0
- data/vendor/plugins/acts_as_tree/test/schema.rb +0 -0
- data/vendor/plugins/classic_pagination/CHANGELOG +152 -0
- data/vendor/plugins/classic_pagination/README +18 -0
- data/vendor/plugins/{output_compression/rakefile → classic_pagination/Rakefile} +22 -22
- data/vendor/plugins/classic_pagination/init.rb +33 -0
- data/vendor/plugins/classic_pagination/install.rb +1 -0
- data/vendor/plugins/classic_pagination/lib/pagination.rb +405 -0
- data/vendor/plugins/classic_pagination/lib/pagination_helper.rb +135 -0
- data/vendor/plugins/classic_pagination/test/fixtures/companies.yml +24 -0
- data/vendor/plugins/classic_pagination/test/fixtures/company.rb +9 -0
- data/vendor/plugins/classic_pagination/test/fixtures/developer.rb +7 -0
- data/vendor/plugins/classic_pagination/test/fixtures/developers.yml +21 -0
- data/vendor/plugins/classic_pagination/test/fixtures/developers_projects.yml +13 -0
- data/vendor/plugins/classic_pagination/test/fixtures/project.rb +3 -0
- data/vendor/plugins/classic_pagination/test/fixtures/projects.yml +7 -0
- data/vendor/plugins/classic_pagination/test/fixtures/replies.yml +13 -0
- data/vendor/plugins/classic_pagination/test/fixtures/reply.rb +5 -0
- data/vendor/plugins/classic_pagination/test/fixtures/schema.sql +42 -0
- data/vendor/plugins/classic_pagination/test/fixtures/topic.rb +3 -0
- data/vendor/plugins/classic_pagination/test/fixtures/topics.yml +22 -0
- data/vendor/plugins/classic_pagination/test/helper.rb +117 -0
- data/vendor/plugins/classic_pagination/test/pagination_helper_test.rb +38 -0
- data/vendor/plugins/classic_pagination/test/pagination_test.rb +177 -0
- data/vendor/plugins/file_column/lib/file_column.rb +1 -1
- data/vendor/plugins/file_column/test/file_column_test.rb +0 -0
- metadata +151 -197
- data/app/helpers/live_tree.rb +0 -238
- data/app/views/elt/_form.rhtml +0 -31
- data/app/views/elt/show_tree.rhtml +0 -8
- data/config/environments/user_environment.rb +0 -1
- data/db/ROOT/Titemagli.txt +0 -3
- data/db/ROOT/titemagli.txt +0 -9
- data/public/javascripts/behaviour.js +0 -254
- data/public/javascripts/ie7-load.htc +0 -1
- data/public/javascripts/ie7.js +0 -6
- data/public/javascripts/live_tree.js +0 -749
- data/public/javascripts/mybehaviour.js +0 -225
- data/public/javascripts/scriptaculous.js +0 -47
- data/public/javascripts/slider.js +0 -283
- data/public/stylesheets/blue.css +0 -471
- data/vendor/plugins/engines/CHANGELOG +0 -241
- data/vendor/plugins/engines/MIT-LICENSE +0 -21
- data/vendor/plugins/engines/README +0 -64
- data/vendor/plugins/engines/Rakefile +0 -32
- data/vendor/plugins/engines/UPGRADING +0 -93
- data/vendor/plugins/engines/about.yml +0 -7
- data/vendor/plugins/engines/generators/plugin_migration/USAGE +0 -45
- data/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb +0 -79
- data/vendor/plugins/engines/generators/plugin_migration/templates/plugin_migration.erb +0 -13
- data/vendor/plugins/engines/init.rb +0 -40
- data/vendor/plugins/engines/install.rb +0 -32
- data/vendor/plugins/engines/lib/engines.rb +0 -323
- data/vendor/plugins/engines/lib/engines/deprecated_config_support.rb +0 -135
- data/vendor/plugins/engines/lib/engines/plugin.rb +0 -214
- data/vendor/plugins/engines/lib/engines/plugin_list.rb +0 -31
- data/vendor/plugins/engines/lib/engines/plugin_migrator.rb +0 -60
- data/vendor/plugins/engines/lib/engines/rails_extensions.rb +0 -6
- data/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb +0 -19
- data/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb +0 -143
- data/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb +0 -155
- data/vendor/plugins/engines/lib/engines/rails_extensions/public_asset_helpers.rb +0 -116
- data/vendor/plugins/engines/lib/engines/rails_extensions/rails.rb +0 -20
- data/vendor/plugins/engines/lib/engines/rails_extensions/rails_initializer.rb +0 -86
- data/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb +0 -77
- data/vendor/plugins/engines/lib/engines/rails_extensions/templates.rb +0 -140
- data/vendor/plugins/engines/lib/engines/testing.rb +0 -87
- data/vendor/plugins/engines/tasks/engines.rake +0 -149
- data/vendor/plugins/login_engine/CHANGELOG +0 -22
- data/vendor/plugins/login_engine/README +0 -344
- data/vendor/plugins/login_engine/app/controllers/user_controller.rb +0 -262
- data/vendor/plugins/login_engine/app/helpers/user_helper.rb +0 -88
- data/vendor/plugins/login_engine/app/models/user.rb +0 -7
- data/vendor/plugins/login_engine/app/models/user_notify.rb +0 -75
- data/vendor/plugins/login_engine/app/views/user/_edit.rhtml +0 -11
- data/vendor/plugins/login_engine/app/views/user/_password.rhtml +0 -9
- data/vendor/plugins/login_engine/app/views/user/change_password.rhtml +0 -17
- data/vendor/plugins/login_engine/app/views/user/edit.rhtml +0 -23
- data/vendor/plugins/login_engine/app/views/user/forgot_password.rhtml +0 -18
- data/vendor/plugins/login_engine/app/views/user/home.rhtml +0 -7
- data/vendor/plugins/login_engine/app/views/user/login.rhtml +0 -17
- data/vendor/plugins/login_engine/app/views/user/logout.rhtml +0 -8
- data/vendor/plugins/login_engine/app/views/user/signup.rhtml +0 -17
- data/vendor/plugins/login_engine/db/migrate/001_initial_schema.rb +0 -25
- data/vendor/plugins/login_engine/init_engine.rb +0 -11
- data/vendor/plugins/login_engine/install.rb +0 -4
- data/vendor/plugins/login_engine/lib/login_engine.rb +0 -62
- data/vendor/plugins/login_engine/lib/login_engine/authenticated_system.rb +0 -113
- data/vendor/plugins/login_engine/lib/login_engine/authenticated_user.rb +0 -155
- data/vendor/plugins/login_engine/public/stylesheets/login_engine.css +0 -81
- data/vendor/plugins/login_engine/test/fixtures/users.yml +0 -41
- data/vendor/plugins/login_engine/test/functional/user_controller_test.rb +0 -536
- data/vendor/plugins/login_engine/test/mocks/mail.rb +0 -14
- data/vendor/plugins/login_engine/test/mocks/time.rb +0 -19
- data/vendor/plugins/login_engine/test/test_helper.rb +0 -11
- data/vendor/plugins/login_engine/test/unit/user_test.rb +0 -114
- data/vendor/plugins/output_compression/MIT-LICENSE +0 -20
- data/vendor/plugins/output_compression/README +0 -4
- data/vendor/plugins/output_compression/init.rb +0 -1
- data/vendor/plugins/output_compression/lib/output_compression.rb +0 -84
- data/vendor/plugins/output_compression/test/output_test.rb +0 -11
- data/vendor/plugins/output_compression/test/test_controller.rb +0 -3
- data/vendor/plugins/output_compression/test/test_helper.rb +0 -14
@@ -0,0 +1,135 @@
|
|
1
|
+
module ActionView
|
2
|
+
module Helpers
|
3
|
+
# Provides methods for linking to ActionController::Pagination objects using a simple generator API. You can optionally
|
4
|
+
# also build your links manually using ActionView::Helpers::AssetHelper#link_to like so:
|
5
|
+
#
|
6
|
+
# <%= link_to "Previous page", { :page => paginator.current.previous } if paginator.current.previous %>
|
7
|
+
# <%= link_to "Next page", { :page => paginator.current.next } if paginator.current.next %>
|
8
|
+
module PaginationHelper
|
9
|
+
unless const_defined?(:DEFAULT_OPTIONS)
|
10
|
+
DEFAULT_OPTIONS = {
|
11
|
+
:name => :page,
|
12
|
+
:window_size => 2,
|
13
|
+
:always_show_anchors => true,
|
14
|
+
:link_to_current_page => false,
|
15
|
+
:params => {}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
# Creates a basic HTML link bar for the given +paginator+. Links will be created
|
20
|
+
# for the next and/or previous page and for a number of other pages around the current
|
21
|
+
# pages position. The +html_options+ hash is passed to +link_to+ when the links are created.
|
22
|
+
#
|
23
|
+
# ==== Options
|
24
|
+
# <tt>:name</tt>:: the routing name for this paginator
|
25
|
+
# (defaults to +page+)
|
26
|
+
# <tt>:prefix</tt>:: prefix for pagination links
|
27
|
+
# (i.e. Older Pages: 1 2 3 4)
|
28
|
+
# <tt>:suffix</tt>:: suffix for pagination links
|
29
|
+
# (i.e. 1 2 3 4 <- Older Pages)
|
30
|
+
# <tt>:window_size</tt>:: the number of pages to show around
|
31
|
+
# the current page (defaults to <tt>2</tt>)
|
32
|
+
# <tt>:always_show_anchors</tt>:: whether or not the first and last
|
33
|
+
# pages should always be shown
|
34
|
+
# (defaults to +true+)
|
35
|
+
# <tt>:link_to_current_page</tt>:: whether or not the current page
|
36
|
+
# should be linked to (defaults to
|
37
|
+
# +false+)
|
38
|
+
# <tt>:params</tt>:: any additional routing parameters
|
39
|
+
# for page URLs
|
40
|
+
#
|
41
|
+
# ==== Examples
|
42
|
+
# # We'll assume we have a paginator setup in @person_pages...
|
43
|
+
#
|
44
|
+
# pagination_links(@person_pages)
|
45
|
+
# # => 1 <a href="/?page=2/">2</a> <a href="/?page=3/">3</a> ... <a href="/?page=10/">10</a>
|
46
|
+
#
|
47
|
+
# pagination_links(@person_pages, :link_to_current_page => true)
|
48
|
+
# # => <a href="/?page=1/">1</a> <a href="/?page=2/">2</a> <a href="/?page=3/">3</a> ... <a href="/?page=10/">10</a>
|
49
|
+
#
|
50
|
+
# pagination_links(@person_pages, :always_show_anchors => false)
|
51
|
+
# # => 1 <a href="/?page=2/">2</a> <a href="/?page=3/">3</a>
|
52
|
+
#
|
53
|
+
# pagination_links(@person_pages, :window_size => 1)
|
54
|
+
# # => 1 <a href="/?page=2/">2</a> ... <a href="/?page=10/">10</a>
|
55
|
+
#
|
56
|
+
# pagination_links(@person_pages, :params => { :viewer => "flash" })
|
57
|
+
# # => 1 <a href="/?page=2&viewer=flash/">2</a> <a href="/?page=3&viewer=flash/">3</a> ...
|
58
|
+
# # <a href="/?page=10&viewer=flash/">10</a>
|
59
|
+
def pagination_links(paginator, options={}, html_options={})
|
60
|
+
name = options[:name] || DEFAULT_OPTIONS[:name]
|
61
|
+
params = (options[:params] || DEFAULT_OPTIONS[:params]).clone
|
62
|
+
|
63
|
+
prefix = options[:prefix] || ''
|
64
|
+
suffix = options[:suffix] || ''
|
65
|
+
|
66
|
+
pagination_links_each(paginator, options, prefix, suffix) do |n|
|
67
|
+
params[name] = n
|
68
|
+
link_to(n.to_s, params, html_options)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Iterate through the pages of a given +paginator+, invoking a
|
73
|
+
# block for each page number that needs to be rendered as a link.
|
74
|
+
#
|
75
|
+
# ==== Options
|
76
|
+
# <tt>:window_size</tt>:: the number of pages to show around
|
77
|
+
# the current page (defaults to +2+)
|
78
|
+
# <tt>:always_show_anchors</tt>:: whether or not the first and last
|
79
|
+
# pages should always be shown
|
80
|
+
# (defaults to +true+)
|
81
|
+
# <tt>:link_to_current_page</tt>:: whether or not the current page
|
82
|
+
# should be linked to (defaults to
|
83
|
+
# +false+)
|
84
|
+
#
|
85
|
+
# ==== Example
|
86
|
+
# # Turn paginated links into an Ajax call
|
87
|
+
# pagination_links_each(paginator, page_options) do |link|
|
88
|
+
# options = { :url => {:action => 'list'}, :update => 'results' }
|
89
|
+
# html_options = { :href => url_for(:action => 'list') }
|
90
|
+
#
|
91
|
+
# link_to_remote(link.to_s, options, html_options)
|
92
|
+
# end
|
93
|
+
def pagination_links_each(paginator, options, prefix = nil, suffix = nil)
|
94
|
+
options = DEFAULT_OPTIONS.merge(options)
|
95
|
+
link_to_current_page = options[:link_to_current_page]
|
96
|
+
always_show_anchors = options[:always_show_anchors]
|
97
|
+
|
98
|
+
current_page = paginator.current_page
|
99
|
+
window_pages = current_page.window(options[:window_size]).pages
|
100
|
+
return if window_pages.length <= 1 unless link_to_current_page
|
101
|
+
|
102
|
+
first, last = paginator.first, paginator.last
|
103
|
+
|
104
|
+
html = ''
|
105
|
+
|
106
|
+
html << prefix if prefix
|
107
|
+
|
108
|
+
if always_show_anchors and not (wp_first = window_pages[0]).first?
|
109
|
+
html << yield(first.number)
|
110
|
+
html << ' ... ' if wp_first.number - first.number > 1
|
111
|
+
html << ' '
|
112
|
+
end
|
113
|
+
|
114
|
+
window_pages.each do |page|
|
115
|
+
if current_page == page && !link_to_current_page
|
116
|
+
html << page.number.to_s
|
117
|
+
else
|
118
|
+
html << yield(page.number)
|
119
|
+
end
|
120
|
+
html << ' '
|
121
|
+
end
|
122
|
+
|
123
|
+
if always_show_anchors and not (wp_last = window_pages[-1]).last?
|
124
|
+
html << ' ... ' if last.number - wp_last.number > 1
|
125
|
+
html << yield(last.number)
|
126
|
+
end
|
127
|
+
|
128
|
+
html << suffix if suffix
|
129
|
+
|
130
|
+
html
|
131
|
+
end
|
132
|
+
|
133
|
+
end # PaginationHelper
|
134
|
+
end # Helpers
|
135
|
+
end # ActionView
|
@@ -0,0 +1,24 @@
|
|
1
|
+
thirty_seven_signals:
|
2
|
+
id: 1
|
3
|
+
name: 37Signals
|
4
|
+
rating: 4
|
5
|
+
|
6
|
+
TextDrive:
|
7
|
+
id: 2
|
8
|
+
name: TextDrive
|
9
|
+
rating: 4
|
10
|
+
|
11
|
+
PlanetArgon:
|
12
|
+
id: 3
|
13
|
+
name: Planet Argon
|
14
|
+
rating: 4
|
15
|
+
|
16
|
+
Google:
|
17
|
+
id: 4
|
18
|
+
name: Google
|
19
|
+
rating: 4
|
20
|
+
|
21
|
+
Ionist:
|
22
|
+
id: 5
|
23
|
+
name: Ioni.st
|
24
|
+
rating: 4
|
@@ -0,0 +1,21 @@
|
|
1
|
+
david:
|
2
|
+
id: 1
|
3
|
+
name: David
|
4
|
+
salary: 80000
|
5
|
+
|
6
|
+
jamis:
|
7
|
+
id: 2
|
8
|
+
name: Jamis
|
9
|
+
salary: 150000
|
10
|
+
|
11
|
+
<% for digit in 3..10 %>
|
12
|
+
dev_<%= digit %>:
|
13
|
+
id: <%= digit %>
|
14
|
+
name: fixture_<%= digit %>
|
15
|
+
salary: 100000
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
poor_jamis:
|
19
|
+
id: 11
|
20
|
+
name: Jamis
|
21
|
+
salary: 9000
|
@@ -0,0 +1,42 @@
|
|
1
|
+
CREATE TABLE 'companies' (
|
2
|
+
'id' INTEGER PRIMARY KEY NOT NULL,
|
3
|
+
'name' TEXT DEFAULT NULL,
|
4
|
+
'rating' INTEGER DEFAULT 1
|
5
|
+
);
|
6
|
+
|
7
|
+
CREATE TABLE 'replies' (
|
8
|
+
'id' INTEGER PRIMARY KEY NOT NULL,
|
9
|
+
'content' text,
|
10
|
+
'created_at' datetime,
|
11
|
+
'updated_at' datetime,
|
12
|
+
'topic_id' integer
|
13
|
+
);
|
14
|
+
|
15
|
+
CREATE TABLE 'topics' (
|
16
|
+
'id' INTEGER PRIMARY KEY NOT NULL,
|
17
|
+
'title' varchar(255),
|
18
|
+
'subtitle' varchar(255),
|
19
|
+
'content' text,
|
20
|
+
'created_at' datetime,
|
21
|
+
'updated_at' datetime
|
22
|
+
);
|
23
|
+
|
24
|
+
CREATE TABLE 'developers' (
|
25
|
+
'id' INTEGER PRIMARY KEY NOT NULL,
|
26
|
+
'name' TEXT DEFAULT NULL,
|
27
|
+
'salary' INTEGER DEFAULT 70000,
|
28
|
+
'created_at' DATETIME DEFAULT NULL,
|
29
|
+
'updated_at' DATETIME DEFAULT NULL
|
30
|
+
);
|
31
|
+
|
32
|
+
CREATE TABLE 'projects' (
|
33
|
+
'id' INTEGER PRIMARY KEY NOT NULL,
|
34
|
+
'name' TEXT DEFAULT NULL
|
35
|
+
);
|
36
|
+
|
37
|
+
CREATE TABLE 'developers_projects' (
|
38
|
+
'developer_id' INTEGER NOT NULL,
|
39
|
+
'project_id' INTEGER NOT NULL,
|
40
|
+
'joined_on' DATE DEFAULT NULL,
|
41
|
+
'access_level' INTEGER DEFAULT 1
|
42
|
+
);
|
@@ -0,0 +1,22 @@
|
|
1
|
+
futurama:
|
2
|
+
id: 1
|
3
|
+
title: Isnt futurama awesome?
|
4
|
+
subtitle: It really is, isnt it.
|
5
|
+
content: I like futurama
|
6
|
+
created_at: <%= 1.day.ago.to_s(:db) %>
|
7
|
+
updated_at:
|
8
|
+
|
9
|
+
harvey_birdman:
|
10
|
+
id: 2
|
11
|
+
title: Harvey Birdman is the king of all men
|
12
|
+
subtitle: yup
|
13
|
+
content: It really is
|
14
|
+
created_at: <%= 2.hours.ago.to_s(:db) %>
|
15
|
+
updated_at:
|
16
|
+
|
17
|
+
rails:
|
18
|
+
id: 3
|
19
|
+
title: Rails is nice
|
20
|
+
subtitle: It makes me happy
|
21
|
+
content: except when I have to hack internals to fix pagination. even then really.
|
22
|
+
created_at: <%= 20.minutes.ago.to_s(:db) %>
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
unless defined?(ActiveRecord)
|
4
|
+
plugin_root = File.join(File.dirname(__FILE__), '..')
|
5
|
+
|
6
|
+
# first look for a symlink to a copy of the framework
|
7
|
+
if framework_root = ["#{plugin_root}/rails", "#{plugin_root}/../../rails"].find { |p| File.directory? p }
|
8
|
+
puts "found framework root: #{framework_root}"
|
9
|
+
# this allows for a plugin to be tested outside an app
|
10
|
+
$:.unshift "#{framework_root}/activesupport/lib", "#{framework_root}/activerecord/lib", "#{framework_root}/actionpack/lib"
|
11
|
+
else
|
12
|
+
# is the plugin installed in an application?
|
13
|
+
app_root = plugin_root + '/../../..'
|
14
|
+
|
15
|
+
if File.directory? app_root + '/config'
|
16
|
+
puts 'using config/boot.rb'
|
17
|
+
ENV['RAILS_ENV'] = 'test'
|
18
|
+
require File.expand_path(app_root + '/config/boot')
|
19
|
+
else
|
20
|
+
# simply use installed gems if available
|
21
|
+
puts 'using rubygems'
|
22
|
+
require 'rubygems'
|
23
|
+
gem 'actionpack'; gem 'activerecord'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
%w(action_pack active_record action_controller active_record/fixtures action_controller/test_process).each {|f| require f}
|
28
|
+
|
29
|
+
Dependencies.load_paths.unshift "#{plugin_root}/lib"
|
30
|
+
end
|
31
|
+
|
32
|
+
# Define the connector
|
33
|
+
class ActiveRecordTestConnector
|
34
|
+
cattr_accessor :able_to_connect
|
35
|
+
cattr_accessor :connected
|
36
|
+
|
37
|
+
# Set our defaults
|
38
|
+
self.connected = false
|
39
|
+
self.able_to_connect = true
|
40
|
+
|
41
|
+
class << self
|
42
|
+
def setup
|
43
|
+
unless self.connected || !self.able_to_connect
|
44
|
+
setup_connection
|
45
|
+
load_schema
|
46
|
+
require_fixture_models
|
47
|
+
self.connected = true
|
48
|
+
end
|
49
|
+
rescue Exception => e # errors from ActiveRecord setup
|
50
|
+
$stderr.puts "\nSkipping ActiveRecord assertion tests: #{e}"
|
51
|
+
#$stderr.puts " #{e.backtrace.join("\n ")}\n"
|
52
|
+
self.able_to_connect = false
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def setup_connection
|
58
|
+
if Object.const_defined?(:ActiveRecord)
|
59
|
+
defaults = { :database => ':memory:' }
|
60
|
+
begin
|
61
|
+
options = defaults.merge :adapter => 'sqlite3', :timeout => 500
|
62
|
+
ActiveRecord::Base.establish_connection(options)
|
63
|
+
ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' => options }
|
64
|
+
ActiveRecord::Base.connection
|
65
|
+
rescue Exception # errors from establishing a connection
|
66
|
+
$stderr.puts 'SQLite 3 unavailable; trying SQLite 2.'
|
67
|
+
options = defaults.merge :adapter => 'sqlite'
|
68
|
+
ActiveRecord::Base.establish_connection(options)
|
69
|
+
ActiveRecord::Base.configurations = { 'sqlite2_ar_integration' => options }
|
70
|
+
ActiveRecord::Base.connection
|
71
|
+
end
|
72
|
+
|
73
|
+
Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')) unless Object.const_defined?(:QUOTED_TYPE)
|
74
|
+
else
|
75
|
+
raise "Can't setup connection since ActiveRecord isn't loaded."
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Load actionpack sqlite tables
|
80
|
+
def load_schema
|
81
|
+
File.read(File.dirname(__FILE__) + "/fixtures/schema.sql").split(';').each do |sql|
|
82
|
+
ActiveRecord::Base.connection.execute(sql) unless sql.blank?
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def require_fixture_models
|
87
|
+
Dir.glob(File.dirname(__FILE__) + "/fixtures/*.rb").each {|f| require f}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Test case for inheritance
|
93
|
+
class ActiveRecordTestCase < Test::Unit::TestCase
|
94
|
+
# Set our fixture path
|
95
|
+
if ActiveRecordTestConnector.able_to_connect
|
96
|
+
self.fixture_path = "#{File.dirname(__FILE__)}/fixtures/"
|
97
|
+
self.use_transactional_fixtures = false
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.fixtures(*args)
|
101
|
+
super if ActiveRecordTestConnector.connected
|
102
|
+
end
|
103
|
+
|
104
|
+
def run(*args)
|
105
|
+
super if ActiveRecordTestConnector.connected
|
106
|
+
end
|
107
|
+
|
108
|
+
# Default so Test::Unit::TestCase doesn't complain
|
109
|
+
def test_truth
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
ActiveRecordTestConnector.setup
|
114
|
+
ActionController::Routing::Routes.reload rescue nil
|
115
|
+
ActionController::Routing::Routes.draw do |map|
|
116
|
+
map.connect ':controller/:action/:id'
|
117
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
require File.dirname(__FILE__) + '/../init'
|
3
|
+
|
4
|
+
class PaginationHelperTest < Test::Unit::TestCase
|
5
|
+
include ActionController::Pagination
|
6
|
+
include ActionView::Helpers::PaginationHelper
|
7
|
+
include ActionView::Helpers::UrlHelper
|
8
|
+
include ActionView::Helpers::TagHelper
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@controller = Class.new do
|
12
|
+
attr_accessor :url, :request
|
13
|
+
def url_for(options, *parameters_for_method_reference)
|
14
|
+
url
|
15
|
+
end
|
16
|
+
end
|
17
|
+
@controller = @controller.new
|
18
|
+
@controller.url = "http://www.example.com"
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_pagination_links
|
22
|
+
total, per_page, page = 30, 10, 1
|
23
|
+
output = pagination_links Paginator.new(@controller, total, per_page, page)
|
24
|
+
assert_equal "1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> ", output
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_pagination_links_with_prefix
|
28
|
+
total, per_page, page = 30, 10, 1
|
29
|
+
output = pagination_links Paginator.new(@controller, total, per_page, page), :prefix => 'Newer '
|
30
|
+
assert_equal "Newer 1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> ", output
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_pagination_links_with_suffix
|
34
|
+
total, per_page, page = 30, 10, 1
|
35
|
+
output = pagination_links Paginator.new(@controller, total, per_page, page), :suffix => 'Older'
|
36
|
+
assert_equal "1 <a href=\"http://www.example.com\">2</a> <a href=\"http://www.example.com\">3</a> Older", output
|
37
|
+
end
|
38
|
+
end
|