Commit 6c3c3a20e61360c5e5ed87b462f444b45cd8025c
1 parent
de9842bd
Exists in
master
and in
27 other branches
Changes neeed to get test/unit/city_test.rb running
It looks to me that this fixes all the problems that would happen at load time.
Showing
36 changed files
with
54 additions
and
242 deletions
Show diff stats
app/controllers/application_controller.rb
... | ... | @@ -59,7 +59,11 @@ class ApplicationController < ActionController::Base |
59 | 59 | # declares that the given <tt>actions</tt> cannot be accessed by other HTTP |
60 | 60 | # method besides POST. |
61 | 61 | def self.post_only(actions, redirect = { :action => 'index'}) |
62 | - verify :method => :post, :only => actions, :redirect_to => redirect | |
62 | + before_filter(:only => actions) do |controller| | |
63 | + if !controller.request.post? | |
64 | + controller.redirect_to redirect | |
65 | + end | |
66 | + end | |
63 | 67 | end |
64 | 68 | |
65 | 69 | helper_method :current_person, :current_person | ... | ... |
app/models/change_password.rb
app/models/contact.rb
1 | -class Contact < ActiveRecord::Base #WithoutTable | |
2 | - tableless :columns => [ | |
3 | - [:name, :string], | |
4 | - [:subject, :string], | |
5 | - [:message, :string], | |
6 | - [:email, :string], | |
7 | - [:state, :string], | |
8 | - [:city, :string], | |
9 | - [:receive_a_copy, :boolean] | |
10 | - ] | |
1 | +class Contact | |
2 | + | |
3 | + include ActiveModel::Validations | |
4 | + | |
5 | + def initialize(attributes = nil) | |
6 | + if attributes | |
7 | + attributes.each do |attr,value| | |
8 | + self.send("#{attr}=", value) | |
9 | + end | |
10 | + end | |
11 | + end | |
12 | + | |
13 | + attr_accessor :name | |
14 | + attr_accessor :subject | |
15 | + attr_accessor :message | |
16 | + attr_accessor :email | |
17 | + attr_accessor :state | |
18 | + attr_accessor :city | |
19 | + attr_accessor :receive_a_copy | |
11 | 20 | attr_accessor :dest |
12 | 21 | attr_accessor :sender |
13 | 22 | ... | ... |
app/models/event.rb
config/initializers/plugins.rb
... | ... | @@ -1,7 +0,0 @@ |
1 | -require 'noosfero/plugin' | |
2 | -require 'noosfero/plugin/hot_spot' | |
3 | -require 'noosfero/plugin/manager' | |
4 | -require 'noosfero/plugin/active_record' | |
5 | -require 'noosfero/plugin/mailer_base' | |
6 | -require 'noosfero/plugin/settings' | |
7 | -Noosfero::Plugin.init_system if $NOOSFERO_LOAD_PLUGINS |
test/functional/application_controller_test.rb
test/functional/contact_controller_test.rb
test/functional/maps_controller_test.rb
test/functional/search_controller_test.rb
test/noosfero_doc_test.rb
test/test_helper.rb
1 | 1 | ENV["RAILS_ENV"] = "test" |
2 | 2 | |
3 | 3 | require File.expand_path(File.dirname(__FILE__) + "/../config/environment") |
4 | -require 'test_help' | |
4 | +require 'rails/test_help' | |
5 | 5 | require 'mocha' |
6 | 6 | require 'tidy' |
7 | 7 | require 'hpricot' |
8 | 8 | |
9 | 9 | require 'noosfero/test' |
10 | +require 'authenticated_test_helper' | |
10 | 11 | require File.dirname(__FILE__) + '/factories' |
11 | 12 | require File.dirname(__FILE__) + '/noosfero_doc_test' |
12 | 13 | require File.dirname(__FILE__) + '/action_tracker_test_helper' |
... | ... | @@ -44,7 +45,7 @@ class ActiveSupport::TestCase |
44 | 45 | # Add more helper methods to be used by all tests here... |
45 | 46 | |
46 | 47 | # for fixture_file_upload |
47 | - include ActionController::TestProcess | |
48 | + include ActionDispatch::TestProcess | |
48 | 49 | |
49 | 50 | include Noosfero::Factory |
50 | 51 | |
... | ... | @@ -52,14 +53,6 @@ class ActiveSupport::TestCase |
52 | 53 | |
53 | 54 | fixtures :environments, :roles |
54 | 55 | |
55 | - def setup | |
56 | - TestSolr.disable | |
57 | - end | |
58 | - | |
59 | - def teardown | |
60 | - TestSolr.disable | |
61 | - end | |
62 | - | |
63 | 56 | def self.all_fixtures |
64 | 57 | Dir.glob(File.join(Rails.root, 'test', 'fixtures', '*.yml')).each do |item| |
65 | 58 | fixtures File.basename(item).sub(/\.yml$/, '').to_s | ... | ... |
test/unit/application_helper_test.rb
test/unit/certifier_test.rb
test/unit/city_test.rb
test/unit/contact_test.rb
test/unit/countries_helper_test.rb
test/unit/doc_section_test.rb
test/unit/doc_topic_test.rb
test/unit/enterprise_test.rb
test/unit/language_helper_test.rb
test/unit/manage_products_helper_test.rb
test/unit/person_test.rb
test/unit/profile_test.rb
test/unit/qualifier_test.rb
test/unit/string_core_ext_test.rb
test/unit/tags_helper_test.rb
test/unit/tiny_mce_article_test.rb
test/unit/user_test.rb
vendor/plugins/active_record_tableless/MIT-LICENSE
... | ... | @@ -1,20 +0,0 @@ |
1 | -Copyright (c) 2008 [name of plugin creator] | |
2 | - | |
3 | -Permission is hereby granted, free of charge, to any person obtaining | |
4 | -a copy of this software and associated documentation files (the | |
5 | -"Software"), to deal in the Software without restriction, including | |
6 | -without limitation the rights to use, copy, modify, merge, publish, | |
7 | -distribute, sublicense, and/or sell copies of the Software, and to | |
8 | -permit persons to whom the Software is furnished to do so, subject to | |
9 | -the following conditions: | |
10 | - | |
11 | -The above copyright notice and this permission notice shall be | |
12 | -included in all copies or substantial portions of the Software. | |
13 | - | |
14 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
15 | -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
16 | -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
17 | -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
18 | -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
19 | -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
20 | -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
vendor/plugins/active_record_tableless/README
... | ... | @@ -1,30 +0,0 @@ |
1 | -ActiveRecordTableless | |
2 | -===================== | |
3 | - | |
4 | -Rails plugin allowing ActiveRecord models to be used with validations but | |
5 | -without being backed by a database table. | |
6 | - | |
7 | - | |
8 | -Install | |
9 | -======= | |
10 | - | |
11 | -script/plugin install git://github.com/robinsp/active_record_tableless.git | |
12 | - | |
13 | - | |
14 | -Example | |
15 | -======= | |
16 | - | |
17 | -class TablelessModel < ActiveRecord::Base | |
18 | - tableless :columns => [ | |
19 | - [:email, :string], | |
20 | - [:password, :string], | |
21 | - [:password_confirmation] | |
22 | - ] | |
23 | - | |
24 | - validates_presence_of :email, :password, :password_confirmation | |
25 | - validates_confirmation_of :password | |
26 | - | |
27 | -end | |
28 | - | |
29 | - | |
30 | -Copyright (c) 2008 [name of plugin creator], released under the MIT license |
vendor/plugins/active_record_tableless/Rakefile
... | ... | @@ -1,22 +0,0 @@ |
1 | -require 'rake' | |
2 | -require 'rake/testtask' | |
3 | -require 'rake/rdoctask' | |
4 | - | |
5 | -desc 'Default: run unit tests.' | |
6 | -task :default => :test | |
7 | - | |
8 | -desc 'Test the active_record_tableless plugin.' | |
9 | -Rake::TestTask.new(:test) do |t| | |
10 | - t.libs << 'lib' | |
11 | - t.pattern = 'test/**/*_test.rb' | |
12 | - t.verbose = true | |
13 | -end | |
14 | - | |
15 | -desc 'Generate documentation for the active_record_tableless plugin.' | |
16 | -Rake::RDocTask.new(:rdoc) do |rdoc| | |
17 | - rdoc.rdoc_dir = 'rdoc' | |
18 | - rdoc.title = 'ActiveRecordTableless' | |
19 | - rdoc.options << '--line-numbers' << '--inline-source' | |
20 | - rdoc.rdoc_files.include('README') | |
21 | - rdoc.rdoc_files.include('lib/**/*.rb') | |
22 | -end |
vendor/plugins/active_record_tableless/init.rb
vendor/plugins/active_record_tableless/lib/active_record/tableless.rb
... | ... | @@ -1,56 +0,0 @@ |
1 | -module ActiveRecord | |
2 | - module Tableless | |
3 | - | |
4 | - def self.included(base) | |
5 | - # 'base' is assumed to be ActiveRecord::Base | |
6 | - base.extend(ClassMethods) | |
7 | - end | |
8 | - | |
9 | - module ClassMethods | |
10 | - def tableless( options = {} ) | |
11 | - include ActiveRecord::Tableless::InstanceMethods | |
12 | - raise "No columns defined" unless options.has_key?(:columns) && !options[:columns].empty? | |
13 | - | |
14 | - self.extend(MetaMethods) | |
15 | - | |
16 | - for column_args in options[:columns] | |
17 | - column( *column_args ) | |
18 | - end | |
19 | - | |
20 | - end | |
21 | - end | |
22 | - | |
23 | - module MetaMethods | |
24 | - def columns() | |
25 | - @columns ||= [] | |
26 | - end | |
27 | - | |
28 | - def column(name, sql_type = nil, default = nil, null = true) | |
29 | - columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) | |
30 | - reset_column_information | |
31 | - end | |
32 | - | |
33 | - # Do not reset @columns | |
34 | - def reset_column_information | |
35 | - generated_methods.each { |name| undef_method(name) } | |
36 | - @column_names = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = nil | |
37 | - end | |
38 | - end | |
39 | - | |
40 | - module InstanceMethods | |
41 | - def create_or_update | |
42 | - errors.empty? | |
43 | - end | |
44 | - | |
45 | - def saved!(with_id = 1) | |
46 | - self.id = with_id | |
47 | - | |
48 | - def self.new_record? | |
49 | - false | |
50 | - end | |
51 | - end | |
52 | - alias_method :exists!, :saved! | |
53 | - end | |
54 | - | |
55 | - end | |
56 | -end | |
57 | 0 | \ No newline at end of file |
vendor/plugins/active_record_tableless/tasks/active_record_tableless_tasks.rake
vendor/plugins/active_record_tableless/test/active_record_tableless_test.rb
... | ... | @@ -1,75 +0,0 @@ |
1 | -require 'test/unit' | |
2 | -require 'rubygems' | |
3 | -require 'active_record' | |
4 | -require File.dirname(__FILE__) + '/../lib/active_record/tableless' | |
5 | - | |
6 | - | |
7 | - | |
8 | -ActiveRecord::Base.establish_connection( { | |
9 | - :adapter => 'sqlite3', | |
10 | - :database => ":memory:", | |
11 | - :timeout => 500 | |
12 | - | |
13 | -}) | |
14 | - | |
15 | -ActiveRecord::Base.send(:include, ActiveRecord::Tableless) | |
16 | - | |
17 | -class TablelessModel < ActiveRecord::Base | |
18 | - tableless :columns => [ | |
19 | - [:email, :string], | |
20 | - [:password, :string], | |
21 | - [:password_confirmation] ] | |
22 | - | |
23 | - validates_presence_of :email, :password, :password_confirmation | |
24 | - validates_confirmation_of :password | |
25 | - | |
26 | -end | |
27 | - | |
28 | -class ActiveRecordTablelessTest < Test::Unit::TestCase | |
29 | - | |
30 | - def setup | |
31 | - super | |
32 | - @valid_attributes = { | |
33 | - :email => "robin@bogus.com", | |
34 | - :password => "password", | |
35 | - :password_confirmation => "password" | |
36 | - } | |
37 | - end | |
38 | - | |
39 | - def test_create | |
40 | - assert TablelessModel.create(@valid_attributes).valid? | |
41 | - end | |
42 | - | |
43 | - def test_validations | |
44 | - # Just check a few validations to make sure we didn't break ActiveRecord::Validations::ClassMethods | |
45 | - assert_not_nil TablelessModel.create(@valid_attributes.merge(:email => "")).errors[:email] | |
46 | - assert_not_nil TablelessModel.create(@valid_attributes.merge(:password => "")).errors[:password] | |
47 | - assert_not_nil TablelessModel.create(@valid_attributes.merge(:password_confirmation => "")).errors[:password] | |
48 | - end | |
49 | - | |
50 | - def test_save | |
51 | - assert TablelessModel.new(@valid_attributes).save | |
52 | - assert !TablelessModel.new(@valid_attributes.merge(:password => "no_match")).save | |
53 | - end | |
54 | - | |
55 | - def test_valid? | |
56 | - assert TablelessModel.new(@valid_attributes).valid? | |
57 | - assert !TablelessModel.new(@valid_attributes.merge(:password => "no_match")).valid? | |
58 | - end | |
59 | - | |
60 | - | |
61 | - def test_exists! | |
62 | - m = TablelessModel.new(@valid_attributes) | |
63 | - | |
64 | - assert_nil m.id | |
65 | - assert m.new_record? | |
66 | - | |
67 | - m.exists! | |
68 | - assert_equal 1, m.id | |
69 | - assert !m.new_record? | |
70 | - | |
71 | - m.exists!(250) | |
72 | - assert_equal 250, m.id | |
73 | - assert !m.new_record? | |
74 | - end | |
75 | -end |
vendor/plugins/noosfero_caching/init.rb
... | ... | @@ -48,8 +48,8 @@ module NoosferoHttpCaching |
48 | 48 | end |
49 | 49 | |
50 | 50 | unless Rails.env.development? |
51 | - middleware = ActionController::Dispatcher.middleware | |
52 | - cookies_mw = ActionController::Session::CookieStore | |
51 | + middleware = Noosfero::Application.config.middleware | |
52 | + cookies_mw = ActionDispatch::Session::CookieStore | |
53 | 53 | ActionController::Base.send(:include, NoosferoHttpCaching) |
54 | 54 | middleware.insert_before(cookies_mw, NoosferoHttpCaching::Middleware) |
55 | 55 | end | ... | ... |