Commit 6c3c3a20e61360c5e5ed87b462f444b45cd8025c

Authored by Antonio Terceiro
1 parent de9842bd

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.
app/controllers/application_controller.rb
@@ -59,7 +59,11 @@ class ApplicationController < ActionController::Base @@ -59,7 +59,11 @@ class ApplicationController < ActionController::Base
59 # declares that the given <tt>actions</tt> cannot be accessed by other HTTP 59 # declares that the given <tt>actions</tt> cannot be accessed by other HTTP
60 # method besides POST. 60 # method besides POST.
61 def self.post_only(actions, redirect = { :action => 'index'}) 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 end 67 end
64 68
65 helper_method :current_person, :current_person 69 helper_method :current_person, :current_person
app/models/change_password.rb
@@ -4,7 +4,7 @@ class ChangePassword &lt; Task @@ -4,7 +4,7 @@ class ChangePassword &lt; Task
4 4
5 def self.human_attribute_name(attrib) 5 def self.human_attribute_name(attrib)
6 case attrib.to_sym 6 case attrib.to_sym
7 - when :login: 7 + when :login
8 _('Username') 8 _('Username')
9 when :email 9 when :email
10 _('e-mail') 10 _('e-mail')
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 attr_accessor :dest 20 attr_accessor :dest
12 attr_accessor :sender 21 attr_accessor :sender
13 22
app/models/event.rb
  1 +require 'noosfero/translatable_content'
  2 +
1 class Event < Article 3 class Event < Article
2 4
3 def self.type_name 5 def self.type_name
config/initializers/plugins.rb
@@ -1,7 +0,0 @@ @@ -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
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 require 'test_controller' 3 require 'test_controller'
3 4
test/functional/contact_controller_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 require 'contact_controller' 3 require 'contact_controller'
3 4
test/functional/maps_controller_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 require 'maps_controller' 3 require 'maps_controller'
3 4
test/functional/search_controller_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 require 'search_controller' 3 require 'search_controller'
3 4
test/noosfero_doc_test.rb
  1 +# encoding: UTF-8
1 require 'mocha' 2 require 'mocha'
2 3
3 module Noosfero::DocTest 4 module Noosfero::DocTest
test/test_helper.rb
1 ENV["RAILS_ENV"] = "test" 1 ENV["RAILS_ENV"] = "test"
2 2
3 require File.expand_path(File.dirname(__FILE__) + "/../config/environment") 3 require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
4 -require 'test_help' 4 +require 'rails/test_help'
5 require 'mocha' 5 require 'mocha'
6 require 'tidy' 6 require 'tidy'
7 require 'hpricot' 7 require 'hpricot'
8 8
9 require 'noosfero/test' 9 require 'noosfero/test'
  10 +require 'authenticated_test_helper'
10 require File.dirname(__FILE__) + '/factories' 11 require File.dirname(__FILE__) + '/factories'
11 require File.dirname(__FILE__) + '/noosfero_doc_test' 12 require File.dirname(__FILE__) + '/noosfero_doc_test'
12 require File.dirname(__FILE__) + '/action_tracker_test_helper' 13 require File.dirname(__FILE__) + '/action_tracker_test_helper'
@@ -44,7 +45,7 @@ class ActiveSupport::TestCase @@ -44,7 +45,7 @@ class ActiveSupport::TestCase
44 # Add more helper methods to be used by all tests here... 45 # Add more helper methods to be used by all tests here...
45 46
46 # for fixture_file_upload 47 # for fixture_file_upload
47 - include ActionController::TestProcess 48 + include ActionDispatch::TestProcess
48 49
49 include Noosfero::Factory 50 include Noosfero::Factory
50 51
@@ -52,14 +53,6 @@ class ActiveSupport::TestCase @@ -52,14 +53,6 @@ class ActiveSupport::TestCase
52 53
53 fixtures :environments, :roles 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 def self.all_fixtures 56 def self.all_fixtures
64 Dir.glob(File.join(Rails.root, 'test', 'fixtures', '*.yml')).each do |item| 57 Dir.glob(File.join(Rails.root, 'test', 'fixtures', '*.yml')).each do |item|
65 fixtures File.basename(item).sub(/\.yml$/, '').to_s 58 fixtures File.basename(item).sub(/\.yml$/, '').to_s
test/unit/application_helper_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 class ApplicationHelperTest < ActiveSupport::TestCase 4 class ApplicationHelperTest < ActiveSupport::TestCase
test/unit/certifier_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 class CertifierTest < ActiveSupport::TestCase 4 class CertifierTest < ActiveSupport::TestCase
test/unit/city_test.rb
1 -require File.dirname(__FILE__) + '/../test_helper' 1 +require 'test_helper.rb'
2 2
3 class CityTest < ActiveSupport::TestCase 3 class CityTest < ActiveSupport::TestCase
4 # Replace this with your real tests. 4 # Replace this with your real tests.
test/unit/contact_test.rb
1 -require File.dirname(__FILE__) + '/../test_helper' 1 +require 'test_helper'
2 2
3 class ContactTest < ActiveSupport::TestCase 3 class ContactTest < ActiveSupport::TestCase
4 4
test/unit/countries_helper_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 class CountriesHelperTest < ActiveSupport::TestCase 4 class CountriesHelperTest < ActiveSupport::TestCase
test/unit/doc_section_test.rb
  1 +# encoding: UTF-8
1 require 'test_helper' 2 require 'test_helper'
2 3
3 class DocSectionTest < ActiveSupport::TestCase 4 class DocSectionTest < ActiveSupport::TestCase
test/unit/doc_topic_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 class DocTopicTest < ActiveSupport::TestCase 4 class DocTopicTest < ActiveSupport::TestCase
test/unit/enterprise_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 class EnterpriseTest < ActiveSupport::TestCase 4 class EnterpriseTest < ActiveSupport::TestCase
test/unit/language_helper_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 class LanguageHelperTest < ActiveSupport::TestCase 4 class LanguageHelperTest < ActiveSupport::TestCase
test/unit/manage_products_helper_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 class ManageProductsHelperTest < ActiveSupport::TestCase 4 class ManageProductsHelperTest < ActiveSupport::TestCase
test/unit/person_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 class PersonTest < ActiveSupport::TestCase 4 class PersonTest < ActiveSupport::TestCase
test/unit/profile_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 class ProfileTest < ActiveSupport::TestCase 4 class ProfileTest < ActiveSupport::TestCase
test/unit/qualifier_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 class QualifierTest < ActiveSupport::TestCase 4 class QualifierTest < ActiveSupport::TestCase
test/unit/string_core_ext_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 # tests for String core extension. See lib/noosfero/core_ext/string.rb 4 # tests for String core extension. See lib/noosfero/core_ext/string.rb
test/unit/tags_helper_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 class TagsHelperTest < ActiveSupport::TestCase 4 class TagsHelperTest < ActiveSupport::TestCase
test/unit/tiny_mce_article_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 class TinyMceArticleTest < ActiveSupport::TestCase 4 class TinyMceArticleTest < ActiveSupport::TestCase
test/unit/user_test.rb
  1 +# encoding: UTF-8
1 require File.dirname(__FILE__) + '/../test_helper' 2 require File.dirname(__FILE__) + '/../test_helper'
2 3
3 class UserTest < ActiveSupport::TestCase 4 class UserTest < ActiveSupport::TestCase
vendor/plugins/active_record_tableless/MIT-LICENSE
@@ -1,20 +0,0 @@ @@ -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,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,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
@@ -1,2 +0,0 @@ @@ -1,2 +0,0 @@
1 -# Include hook code here  
2 -ActiveRecord::Base.send(:include, ActiveRecord::Tableless)  
3 \ No newline at end of file 0 \ No newline at end of file
vendor/plugins/active_record_tableless/lib/active_record/tableless.rb
@@ -1,56 +0,0 @@ @@ -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 \ No newline at end of file 0 \ No newline at end of file
vendor/plugins/active_record_tableless/tasks/active_record_tableless_tasks.rake
@@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
1 -# desc "Explaining what the task does"  
2 -# task :active_record_tableless do  
3 -# # Task goes here  
4 -# end  
vendor/plugins/active_record_tableless/test/active_record_tableless_test.rb
@@ -1,75 +0,0 @@ @@ -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,8 +48,8 @@ module NoosferoHttpCaching
48 end 48 end
49 49
50 unless Rails.env.development? 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 ActionController::Base.send(:include, NoosferoHttpCaching) 53 ActionController::Base.send(:include, NoosferoHttpCaching)
54 middleware.insert_before(cookies_mw, NoosferoHttpCaching::Middleware) 54 middleware.insert_before(cookies_mw, NoosferoHttpCaching::Middleware)
55 end 55 end