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
data/script/destroy
CHANGED
File without changes
|
data/script/generate
CHANGED
File without changes
|
data/script/plugin
CHANGED
File without changes
|
data/script/profiler
CHANGED
File without changes
|
data/script/runner
CHANGED
File without changes
|
data/script/server
CHANGED
File without changes
|
data/script/spec
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
if ARGV.any? {|arg| %w[--drb -X --generate-options -G --help -h --version -v].include?(arg)}
|
3
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
4
|
+
else
|
5
|
+
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
|
6
|
+
ENV["RAILS_ENV"] ||= 'test'
|
7
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(RAILS_ROOT)
|
8
|
+
end
|
9
|
+
require 'spec/autorun'
|
10
|
+
exit ::Spec::Runner::CommandLine.run
|
data/script/spec_server
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
|
3
|
+
|
4
|
+
puts "Loading Rails environment"
|
5
|
+
ENV["RAILS_ENV"] ||= 'test'
|
6
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(RAILS_ROOT)
|
7
|
+
|
8
|
+
require 'optparse'
|
9
|
+
require 'spec/rails/spec_server'
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
|
-
class AttachmentTest <
|
3
|
+
class AttachmentTest < ActiveSupport::TestCase
|
4
4
|
fixtures :elts, :mails, :attachments
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def setup
|
7
|
+
@attachment = Attachment.find('0')
|
8
|
+
end
|
9
9
|
|
10
10
|
# Replace this with your real tests.
|
11
11
|
def test_truth
|
data/test/unit/choice_test.rb
CHANGED
data/test/unit/elt_test.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
|
-
class EltTest <
|
4
|
-
|
3
|
+
class EltTest < ActiveSupport::TestCase
|
4
|
+
fixtures :people, :users, :elts, :mails, :attachments, :subscriptions
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def setup
|
7
|
+
@elt = Elt.find('1')
|
8
|
+
end
|
9
9
|
|
10
|
-
|
10
|
+
def test_generated_id
|
11
11
|
e = @elt.children.new
|
12
12
|
e.subject = "\"Test: /de, .. -\ #?&subject!\""
|
13
13
|
e.body = "Test de body"
|
@@ -23,9 +23,9 @@ class EltTest < Test::Unit::TestCase
|
|
23
23
|
@elt.add_child e
|
24
24
|
|
25
25
|
assert_equal "Test_de_subject_1", e.id
|
26
|
-
|
26
|
+
end
|
27
27
|
|
28
|
-
|
28
|
+
def test_vote_hidden_from_view
|
29
29
|
vote = @elt.children.new
|
30
30
|
vote.save
|
31
31
|
@elt.add_child vote
|
@@ -34,7 +34,7 @@ class EltTest < Test::Unit::TestCase
|
|
34
34
|
|
35
35
|
assert_equal -1, vote.result
|
36
36
|
assert_equal 1, vote.parent.result
|
37
|
-
|
37
|
+
end
|
38
38
|
|
39
39
|
def test_position
|
40
40
|
e = @elt.children.new
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
require 'mail_notify'
|
3
3
|
|
4
|
-
class MailNotifyTest <
|
5
|
-
|
4
|
+
class MailNotifyTest < ActiveSupport::TestCase
|
5
|
+
fixtures :elts, :mails, :attachments, :people, :users, :subscriptions
|
6
6
|
|
7
7
|
def setup
|
8
8
|
ActionMailer::Base.delivery_method = :test
|
data/test/unit/mail_test.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
|
-
class MailTest <
|
4
|
-
|
3
|
+
class MailTest < ActiveSupport::TestCase
|
4
|
+
fixtures :people, :users, :elts, :mails, :attachments, :subscriptions
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def setup
|
7
|
+
@mail = Mail.find('1')
|
8
|
+
end
|
9
9
|
|
10
10
|
def test_receive
|
11
11
|
ActionMailer::Base.deliveries = []
|
@@ -23,7 +23,7 @@ class MailTest < Test::Unit::TestCase
|
|
23
23
|
assert_equal (eltsCount + 2), Elt.count
|
24
24
|
# manu@noos.fr, manu@localhost
|
25
25
|
# delivering elt and parent's
|
26
|
-
assert_equal (deliveredMailsCount +
|
26
|
+
assert_equal (deliveredMailsCount + 3), ActionMailer::Base.deliveries.size
|
27
27
|
assert_equal mailFile.message_id, ActionMailer::Base.deliveries[1].message_id
|
28
28
|
end
|
29
29
|
|
@@ -291,7 +291,7 @@ class MailTest < Test::Unit::TestCase
|
|
291
291
|
deliveredMailsCount = ActionMailer::Base.deliveries.size
|
292
292
|
mail = TMail::Mail.parse(read_fixture('avatar').to_s)
|
293
293
|
elt = Mail.receive(mail).elt
|
294
|
-
assert_equal deliveredMailsCount +
|
294
|
+
assert_equal deliveredMailsCount + 3, ActionMailer::Base.deliveries.size
|
295
295
|
assert_equal 1, elt.attachments.size
|
296
296
|
assert_equal "image/jpeg", elt.attachments.first.content_type
|
297
297
|
assert_equal 2, ActionMailer::Base.deliveries.last.parts.size
|
@@ -305,13 +305,20 @@ class MailTest < Test::Unit::TestCase
|
|
305
305
|
elt = Mail.receive(mail).elt
|
306
306
|
# people and avatar mail!
|
307
307
|
#puts "--------------------------"
|
308
|
-
assert_equal deliveredMailsCount +
|
308
|
+
assert_equal deliveredMailsCount + 3, ActionMailer::Base.deliveries.size
|
309
309
|
|
310
310
|
# TODO make sure the pseudo parent has a vote "result"!!!
|
311
|
-
assert_equal elt.all_recipients.size, PersonMail.count
|
311
|
+
assert_equal elt.all_recipients.size, PersonMail.count / 2
|
312
312
|
# Again, to check there is no second sending
|
313
313
|
elt.publish
|
314
|
-
assert_equal elt.all_recipients.size, PersonMail.count
|
314
|
+
assert_equal elt.all_recipients.size, PersonMail.count / 2
|
315
315
|
end
|
316
|
-
end
|
317
316
|
|
317
|
+
def test_send_and_record_mails
|
318
|
+
#puts "test_send_and_record_mails"
|
319
|
+
ActionMailer::Base.deliveries = []
|
320
|
+
deliveredMailsCount = ActionMailer::Base.deliveries.size
|
321
|
+
mail = TMail::Mail.parse(read_fixture('file').to_s)
|
322
|
+
elt = Mail.receive(mail).elt
|
323
|
+
end
|
324
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
require 'person_notify'
|
3
3
|
|
4
|
-
class PersonNotifyTest <
|
4
|
+
class PersonNotifyTest < ActiveSupport::TestCase
|
5
5
|
def setup
|
6
6
|
ActionMailer::Base.delivery_method = :test
|
7
7
|
ActionMailer::Base.perform_deliveries = true
|
data/test/unit/person_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
|
-
class PersonTest <
|
3
|
+
class PersonTest < ActiveSupport::TestCase
|
4
4
|
#fixtures :people, LoginEngine.config(:user_table).to_sym
|
5
5
|
fixtures :people, :users, :elts, :mails, :attachments, :subscriptions
|
6
6
|
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class UserTest < ActiveSupport::TestCase
|
4
|
+
fixtures :users
|
5
|
+
|
6
|
+
def setup
|
7
|
+
LOGIN_ENGINE[:salt] = "test-salt"
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_auth
|
11
|
+
assert_equal users(:bob), User.authenticate("bob", "atest")
|
12
|
+
assert_nil User.authenticate("nonbob", "atest")
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_passwordchange
|
16
|
+
users(:longbob).change_password("nonbobpasswd")
|
17
|
+
users(:longbob).save
|
18
|
+
assert_equal users(:longbob), User.authenticate("longbob", "nonbobpasswd")
|
19
|
+
assert_nil User.authenticate("longbob", "alongtest")
|
20
|
+
users(:longbob).change_password("alongtest")
|
21
|
+
users(:longbob).save
|
22
|
+
assert_equal users(:longbob), User.authenticate("longbob", "alongtest")
|
23
|
+
assert_nil User.authenticate("longbob", "nonbobpasswd")
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_disallowed_passwords
|
27
|
+
u = User.new
|
28
|
+
u.login = "nonbob"
|
29
|
+
u.email = "bobs@email.com"
|
30
|
+
|
31
|
+
u.change_password("tiny")
|
32
|
+
assert !u.save
|
33
|
+
assert u.errors.invalid?('password')
|
34
|
+
|
35
|
+
u.change_password("hugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehuge")
|
36
|
+
assert !u.save
|
37
|
+
assert u.errors.invalid?('password')
|
38
|
+
|
39
|
+
u.change_password("")
|
40
|
+
assert !u.save
|
41
|
+
assert u.errors.invalid?('password')
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_bad_logins
|
45
|
+
u = User.new
|
46
|
+
u.change_password("bobs_secure_password")
|
47
|
+
u.email = "bobs@email.com"
|
48
|
+
|
49
|
+
u.login = "x"
|
50
|
+
assert !u.save
|
51
|
+
assert u.errors.invalid?('login')
|
52
|
+
|
53
|
+
u.login = "hugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhug"
|
54
|
+
assert !u.save
|
55
|
+
assert u.errors.invalid?('login')
|
56
|
+
|
57
|
+
u.login = ""
|
58
|
+
assert !u.save
|
59
|
+
assert u.errors.invalid?('login')
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_collision
|
63
|
+
u = User.new
|
64
|
+
u.login = "existingbob"
|
65
|
+
u.change_password("bobs_secure_password")
|
66
|
+
assert !u.save
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_email_should_be_nominally_valid
|
70
|
+
u = User.new
|
71
|
+
u.login = "email_test"
|
72
|
+
u.change_password("email_test_password")
|
73
|
+
|
74
|
+
assert !u.save
|
75
|
+
assert u.errors.invalid?('email')
|
76
|
+
|
77
|
+
u.email = "invalid_email"
|
78
|
+
assert !u.save
|
79
|
+
assert u.errors.invalid?('email')
|
80
|
+
end
|
81
|
+
end
|
data/test/unit/visit_test.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
|
-
class VisitTest <
|
4
|
-
|
3
|
+
class VisitTest < ActiveSupport::TestCase
|
4
|
+
fixtures :visits
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
# Replace this with your real tests.
|
7
|
+
def test_truth
|
8
|
+
assert true
|
9
|
+
end
|
10
10
|
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
# Postgres and MySQL by bubbleware.com
|
2
|
+
# Oracle and cleanups by atmos.org
|
3
|
+
require 'digest/sha1'
|
4
|
+
|
5
|
+
module ActiveRecord
|
6
|
+
class SchemaDumper
|
7
|
+
private
|
8
|
+
alias old_tables tables
|
9
|
+
def tables(stream)
|
10
|
+
old_tables(stream)
|
11
|
+
@connection.tables.sort.each do |tbl|
|
12
|
+
next if tbl == "schema_info"
|
13
|
+
foreign_key_constraints(tbl, stream)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def foreign_key_constraints(table, stream)
|
18
|
+
keys = @connection.foreign_key_constraints(table)
|
19
|
+
keys.each do |key|
|
20
|
+
stream.print " add_foreign_key_constraint #{table.inspect}, #{key.foreign_key.inspect}, #{key.reference_table.inspect}, #{key.reference_column.inspect}, :name => #{key.name.inspect}, :on_update => #{key.on_update.inspect}, :on_delete => #{key.on_delete.inspect}"
|
21
|
+
stream.puts
|
22
|
+
end
|
23
|
+
stream.puts unless keys.empty?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module ConnectionAdapters
|
28
|
+
class ForeignKeyConstraintDefinition < Struct.new(:name, :foreign_key, :reference_table, :reference_column, :on_update, :on_delete) #:nodoc:
|
29
|
+
end
|
30
|
+
|
31
|
+
class AbstractAdapter
|
32
|
+
protected
|
33
|
+
def symbolize_foreign_key_constraint_action(constraint_action)
|
34
|
+
constraint_action.downcase.gsub(/\s/, '_').to_sym
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class PostgreSQLAdapter < AbstractAdapter
|
39
|
+
def foreign_key_constraints(table, name = nil)
|
40
|
+
sql = "SELECT conname, pg_catalog.pg_get_constraintdef(oid) AS consrc FROM pg_catalog.pg_constraint WHERE contype='f' "
|
41
|
+
sql += "AND conrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='#{table}')"
|
42
|
+
|
43
|
+
query(sql,name).collect do |row|
|
44
|
+
if row[1] =~ /FOREIGN KEY \((.+)\) REFERENCES (.+)\((.+)\)(?: ON UPDATE (\w+))?(?: ON DELETE (\w+))?/
|
45
|
+
ForeignKeyConstraintDefinition.new(row[0], $1, $2, $3,
|
46
|
+
($4 ? symbolize_foreign_key_constraint_action($4) : nil),
|
47
|
+
($5 ? symbolize_foreign_key_constraint_action($5) : nil))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def remove_foreign_key_constraint(table_name, constraint_name)
|
53
|
+
execute "ALTER TABLE #{table_name} DROP CONSTRAINT #{constraint_name}"
|
54
|
+
end
|
55
|
+
|
56
|
+
#alias old_default_value default_value
|
57
|
+
#def default_value(value)
|
58
|
+
# return ":now" if value =~ /^now\(\)|^\('now'::text\)::(date|timestamp)/i
|
59
|
+
# return old_default_value(value)
|
60
|
+
#end
|
61
|
+
end
|
62
|
+
|
63
|
+
class OracleAdapter < AbstractAdapter
|
64
|
+
def foreign_key_constraints(table, name = nil)
|
65
|
+
uc = 'user_constraints'
|
66
|
+
ucc = 'user_cons_columns'
|
67
|
+
|
68
|
+
sql = %Q{SELECT
|
69
|
+
c.table_name, cc.column_name,
|
70
|
+
r.table_name as rtable_name, rc.column_name as rcolumn_name,
|
71
|
+
c.delete_rule
|
72
|
+
from
|
73
|
+
#{uc} c, #{uc} r, #{ucc} cc, #{ucc} rc
|
74
|
+
where
|
75
|
+
c.constraint_type = 'R' and
|
76
|
+
c.table_name = UPPER('#{table}') and
|
77
|
+
c.r_constraint_name = r.constraint_name and
|
78
|
+
c.constraint_name = cc.constraint_name and
|
79
|
+
r.constraint_name = rc.constraint_name and
|
80
|
+
cc.position = rc.position}.gsub(/(\n|^\W+)/, ' ')
|
81
|
+
|
82
|
+
select(sql).collect do |row|
|
83
|
+
ForeignKeyConstraintDefinition.new('', row['column_name'].downcase,
|
84
|
+
row['rtable_name'].downcase, row['rcolumn_name'].downcase,
|
85
|
+
nil, symbolize_foreign_key_constraint_action(row['delete_rule']))
|
86
|
+
end
|
87
|
+
end
|
88
|
+
def remove_foreign_key_constraint(table_name, constraint_name)
|
89
|
+
constraint = 'c'+Digest::SHA1.hexdigest(constraint_name)[0,29]
|
90
|
+
execute "ALTER TABLE #{table_name} DROP FOREIGN KEY #{constraint}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
class MysqlAdapter < AbstractAdapter
|
95
|
+
def foreign_key_constraints(table, name = nil)
|
96
|
+
constraints = []
|
97
|
+
execute("SHOW CREATE TABLE #{table}", name).each do |row|
|
98
|
+
row[1].each do |create_line|
|
99
|
+
if create_line.strip =~ /CONSTRAINT `([^`]+)` FOREIGN KEY \(`([^`]+)`\) REFERENCES `([^`]+)` \(`([^`]+)`\)([^,]*)/
|
100
|
+
constraint = ForeignKeyConstraintDefinition.new(Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3), Regexp.last_match(4), nil, nil)
|
101
|
+
|
102
|
+
constraint_params = {}
|
103
|
+
|
104
|
+
unless Regexp.last_match(5).nil?
|
105
|
+
Regexp.last_match(5).strip.split('ON ').each do |param|
|
106
|
+
constraint_params[Regexp.last_match(1).upcase] = Regexp.last_match(2).strip.upcase if param.strip =~ /([^ ]+) (.+)/
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
constraint.on_update = symbolize_foreign_key_constraint_action(constraint_params['UPDATE']) if constraint_params.include? 'UPDATE'
|
111
|
+
constraint.on_delete = symbolize_foreign_key_constraint_action(constraint_params['DELETE']) if constraint_params.include? 'DELETE'
|
112
|
+
|
113
|
+
constraints << constraint
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
constraints
|
119
|
+
end
|
120
|
+
|
121
|
+
def remove_foreign_key_constraint(table_name, constraint_name)
|
122
|
+
execute "ALTER TABLE #{table_name} DROP FOREIGN KEY #{constraint_name}"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
class Column
|
126
|
+
private
|
127
|
+
alias old_extract_limit extract_limit
|
128
|
+
def extract_limit(sql_type)
|
129
|
+
return 255 if sql_type =~ /enum/i
|
130
|
+
old_extract_limit(sql_type)
|
131
|
+
end
|
132
|
+
|
133
|
+
alias old_simplified_type simplified_type
|
134
|
+
def simplified_type(field_type)
|
135
|
+
return :string if field_type =~ /enum/i
|
136
|
+
old_simplified_type(field_type)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
module SchemaStatements
|
141
|
+
# Adds a new foreign key constraint to the table.
|
142
|
+
#
|
143
|
+
# The constrinat will be named after the table and the reference table and column
|
144
|
+
# unless you pass +:name+ as an option.
|
145
|
+
#
|
146
|
+
# options: :name, :on_update, :on_delete
|
147
|
+
def foreign_key_constraint_statement(condition, fkc_sym)
|
148
|
+
action = { :restrict => 'RESTRICT', :cascade => 'CASCADE', :set_null => 'SET NULL' }[fkc_sym]
|
149
|
+
action ? ' ON ' << condition << ' ' << action : ''
|
150
|
+
end
|
151
|
+
|
152
|
+
def add_foreign_key_constraint(table_name, foreign_key, reference_table, reference_column, options = {})
|
153
|
+
# sqlite and fks don't mix well, http://www.sqlite.org/cvstrac/wiki?p=ForeignKeyTriggers
|
154
|
+
return if adapter_name =~ /^sqlite/i
|
155
|
+
constraint_name = options[:name] || "#{table_name}_ibfk_#{foreign_key}"
|
156
|
+
|
157
|
+
# oracle chokes on constraints longer than 30 chars
|
158
|
+
if adapter_name =~ /^(oci|oracle)$/i
|
159
|
+
constraint_name = 'c'+Digest::SHA1.hexdigest(constraint_name)[0,29]
|
160
|
+
end
|
161
|
+
|
162
|
+
sql = "ALTER TABLE #{table_name} ADD CONSTRAINT #{constraint_name} FOREIGN KEY (#{foreign_key}) REFERENCES #{reference_table} (#{reference_column})"
|
163
|
+
|
164
|
+
sql << foreign_key_constraint_statement('UPDATE', options[:on_update])
|
165
|
+
sql << foreign_key_constraint_statement('DELETE', options[:on_delete])
|
166
|
+
|
167
|
+
execute sql
|
168
|
+
end
|
169
|
+
|
170
|
+
# options: Must enter one of the two options:
|
171
|
+
# 1) :name => the name of the foreign key constraint
|
172
|
+
# 2) :foreign_key => the name of the column for which the foreign key was created
|
173
|
+
# (only if the default constraint_name was used)
|
174
|
+
def remove_foreign_key_constraint(table_name, options={})
|
175
|
+
constraint_name = options[:name] || "#{table_name}_ibfk_#{foreign_key}"
|
176
|
+
raise ArgumentError, "You must specify the constraint name" if constraint_name.blank?
|
177
|
+
|
178
|
+
@connection.remove_foreign_key_constraint(table_name, constraint_name)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|