diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 06fddc6..bc16d36 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -59,7 +59,11 @@ class ApplicationController < ActionController::Base # declares that the given actions cannot be accessed by other HTTP # method besides POST. def self.post_only(actions, redirect = { :action => 'index'}) - verify :method => :post, :only => actions, :redirect_to => redirect + before_filter(:only => actions) do |controller| + if !controller.request.post? + controller.redirect_to redirect + end + end end helper_method :current_person, :current_person diff --git a/app/models/change_password.rb b/app/models/change_password.rb index 2f85776..60db0af 100644 --- a/app/models/change_password.rb +++ b/app/models/change_password.rb @@ -4,7 +4,7 @@ class ChangePassword < Task def self.human_attribute_name(attrib) case attrib.to_sym - when :login: + when :login _('Username') when :email _('e-mail') diff --git a/app/models/contact.rb b/app/models/contact.rb index 459b7a8..980a784 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -1,13 +1,22 @@ -class Contact < ActiveRecord::Base #WithoutTable - tableless :columns => [ - [:name, :string], - [:subject, :string], - [:message, :string], - [:email, :string], - [:state, :string], - [:city, :string], - [:receive_a_copy, :boolean] - ] +class Contact + + include ActiveModel::Validations + + def initialize(attributes = nil) + if attributes + attributes.each do |attr,value| + self.send("#{attr}=", value) + end + end + end + + attr_accessor :name + attr_accessor :subject + attr_accessor :message + attr_accessor :email + attr_accessor :state + attr_accessor :city + attr_accessor :receive_a_copy attr_accessor :dest attr_accessor :sender diff --git a/app/models/event.rb b/app/models/event.rb index 5732c0d..f20aa5d 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -1,3 +1,5 @@ +require 'noosfero/translatable_content' + class Event < Article def self.type_name diff --git a/config/initializers/plugins.rb b/config/initializers/plugins.rb deleted file mode 100644 index 7c95396..0000000 --- a/config/initializers/plugins.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'noosfero/plugin' -require 'noosfero/plugin/hot_spot' -require 'noosfero/plugin/manager' -require 'noosfero/plugin/active_record' -require 'noosfero/plugin/mailer_base' -require 'noosfero/plugin/settings' -Noosfero::Plugin.init_system if $NOOSFERO_LOAD_PLUGINS diff --git a/test/functional/application_controller_test.rb b/test/functional/application_controller_test.rb index 4c68a34..aa30353 100644 --- a/test/functional/application_controller_test.rb +++ b/test/functional/application_controller_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' require 'test_controller' diff --git a/test/functional/contact_controller_test.rb b/test/functional/contact_controller_test.rb index f30f56b..7d54b97 100644 --- a/test/functional/contact_controller_test.rb +++ b/test/functional/contact_controller_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' require 'contact_controller' diff --git a/test/functional/maps_controller_test.rb b/test/functional/maps_controller_test.rb index 42fc995..603385c 100644 --- a/test/functional/maps_controller_test.rb +++ b/test/functional/maps_controller_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' require 'maps_controller' diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index 661abb9..b62330e 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' require 'search_controller' diff --git a/test/noosfero_doc_test.rb b/test/noosfero_doc_test.rb index e4977f1..2f577ee 100644 --- a/test/noosfero_doc_test.rb +++ b/test/noosfero_doc_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require 'mocha' module Noosfero::DocTest diff --git a/test/test_helper.rb b/test/test_helper.rb index 58f84fa..d767720 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,12 +1,13 @@ ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") -require 'test_help' +require 'rails/test_help' require 'mocha' require 'tidy' require 'hpricot' require 'noosfero/test' +require 'authenticated_test_helper' require File.dirname(__FILE__) + '/factories' require File.dirname(__FILE__) + '/noosfero_doc_test' require File.dirname(__FILE__) + '/action_tracker_test_helper' @@ -44,7 +45,7 @@ class ActiveSupport::TestCase # Add more helper methods to be used by all tests here... # for fixture_file_upload - include ActionController::TestProcess + include ActionDispatch::TestProcess include Noosfero::Factory @@ -52,14 +53,6 @@ class ActiveSupport::TestCase fixtures :environments, :roles - def setup - TestSolr.disable - end - - def teardown - TestSolr.disable - end - def self.all_fixtures Dir.glob(File.join(Rails.root, 'test', 'fixtures', '*.yml')).each do |item| fixtures File.basename(item).sub(/\.yml$/, '').to_s diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index f2379b5..1349839 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' class ApplicationHelperTest < ActiveSupport::TestCase diff --git a/test/unit/certifier_test.rb b/test/unit/certifier_test.rb index 3b67adf..1c0accf 100644 --- a/test/unit/certifier_test.rb +++ b/test/unit/certifier_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' class CertifierTest < ActiveSupport::TestCase diff --git a/test/unit/city_test.rb b/test/unit/city_test.rb index 06ed459..662809e 100644 --- a/test/unit/city_test.rb +++ b/test/unit/city_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../test_helper' +require 'test_helper.rb' class CityTest < ActiveSupport::TestCase # Replace this with your real tests. diff --git a/test/unit/contact_test.rb b/test/unit/contact_test.rb index bdb0753..6d0b2e2 100644 --- a/test/unit/contact_test.rb +++ b/test/unit/contact_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../test_helper' +require 'test_helper' class ContactTest < ActiveSupport::TestCase diff --git a/test/unit/countries_helper_test.rb b/test/unit/countries_helper_test.rb index 29bf8e5..1cd3a9e 100644 --- a/test/unit/countries_helper_test.rb +++ b/test/unit/countries_helper_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' class CountriesHelperTest < ActiveSupport::TestCase diff --git a/test/unit/doc_section_test.rb b/test/unit/doc_section_test.rb index 2a82e0d..64e8303 100644 --- a/test/unit/doc_section_test.rb +++ b/test/unit/doc_section_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require 'test_helper' class DocSectionTest < ActiveSupport::TestCase diff --git a/test/unit/doc_topic_test.rb b/test/unit/doc_topic_test.rb index 5976e3d..152e478 100644 --- a/test/unit/doc_topic_test.rb +++ b/test/unit/doc_topic_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' class DocTopicTest < ActiveSupport::TestCase diff --git a/test/unit/enterprise_test.rb b/test/unit/enterprise_test.rb index 365f100..6c86955 100644 --- a/test/unit/enterprise_test.rb +++ b/test/unit/enterprise_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' class EnterpriseTest < ActiveSupport::TestCase diff --git a/test/unit/language_helper_test.rb b/test/unit/language_helper_test.rb index 18db520..a371518 100644 --- a/test/unit/language_helper_test.rb +++ b/test/unit/language_helper_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' class LanguageHelperTest < ActiveSupport::TestCase diff --git a/test/unit/manage_products_helper_test.rb b/test/unit/manage_products_helper_test.rb index af7a6c5..39f907f 100644 --- a/test/unit/manage_products_helper_test.rb +++ b/test/unit/manage_products_helper_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' class ManageProductsHelperTest < ActiveSupport::TestCase diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index 2534207..51d29ee 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' class PersonTest < ActiveSupport::TestCase diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 41ce20d..2af1685 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' class ProfileTest < ActiveSupport::TestCase diff --git a/test/unit/qualifier_test.rb b/test/unit/qualifier_test.rb index 213c576..f14bbd3 100644 --- a/test/unit/qualifier_test.rb +++ b/test/unit/qualifier_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' class QualifierTest < ActiveSupport::TestCase diff --git a/test/unit/string_core_ext_test.rb b/test/unit/string_core_ext_test.rb index 12838c8..3a80565 100644 --- a/test/unit/string_core_ext_test.rb +++ b/test/unit/string_core_ext_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' # tests for String core extension. See lib/noosfero/core_ext/string.rb diff --git a/test/unit/tags_helper_test.rb b/test/unit/tags_helper_test.rb index 5f226dc..c6115df 100644 --- a/test/unit/tags_helper_test.rb +++ b/test/unit/tags_helper_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' class TagsHelperTest < ActiveSupport::TestCase diff --git a/test/unit/tiny_mce_article_test.rb b/test/unit/tiny_mce_article_test.rb index 5467360..369227c 100644 --- a/test/unit/tiny_mce_article_test.rb +++ b/test/unit/tiny_mce_article_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' class TinyMceArticleTest < ActiveSupport::TestCase diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 69fe1a5..d03c440 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 require File.dirname(__FILE__) + '/../test_helper' class UserTest < ActiveSupport::TestCase diff --git a/vendor/plugins/active_record_tableless/MIT-LICENSE b/vendor/plugins/active_record_tableless/MIT-LICENSE deleted file mode 100644 index 8eaf6db..0000000 --- a/vendor/plugins/active_record_tableless/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2008 [name of plugin creator] - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/active_record_tableless/README b/vendor/plugins/active_record_tableless/README deleted file mode 100644 index a441fb8..0000000 --- a/vendor/plugins/active_record_tableless/README +++ /dev/null @@ -1,30 +0,0 @@ -ActiveRecordTableless -===================== - -Rails plugin allowing ActiveRecord models to be used with validations but -without being backed by a database table. - - -Install -======= - -script/plugin install git://github.com/robinsp/active_record_tableless.git - - -Example -======= - -class TablelessModel < ActiveRecord::Base - tableless :columns => [ - [:email, :string], - [:password, :string], - [:password_confirmation] - ] - - validates_presence_of :email, :password, :password_confirmation - validates_confirmation_of :password - -end - - -Copyright (c) 2008 [name of plugin creator], released under the MIT license diff --git a/vendor/plugins/active_record_tableless/Rakefile b/vendor/plugins/active_record_tableless/Rakefile deleted file mode 100644 index 6dc7c30..0000000 --- a/vendor/plugins/active_record_tableless/Rakefile +++ /dev/null @@ -1,22 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the active_record_tableless plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the active_record_tableless plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'ActiveRecordTableless' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end diff --git a/vendor/plugins/active_record_tableless/init.rb b/vendor/plugins/active_record_tableless/init.rb deleted file mode 100644 index d145fdd..0000000 --- a/vendor/plugins/active_record_tableless/init.rb +++ /dev/null @@ -1,2 +0,0 @@ -# Include hook code here -ActiveRecord::Base.send(:include, ActiveRecord::Tableless) \ No newline at end of file diff --git a/vendor/plugins/active_record_tableless/lib/active_record/tableless.rb b/vendor/plugins/active_record_tableless/lib/active_record/tableless.rb deleted file mode 100644 index 289e95c..0000000 --- a/vendor/plugins/active_record_tableless/lib/active_record/tableless.rb +++ /dev/null @@ -1,56 +0,0 @@ -module ActiveRecord - module Tableless - - def self.included(base) - # 'base' is assumed to be ActiveRecord::Base - base.extend(ClassMethods) - end - - module ClassMethods - def tableless( options = {} ) - include ActiveRecord::Tableless::InstanceMethods - raise "No columns defined" unless options.has_key?(:columns) && !options[:columns].empty? - - self.extend(MetaMethods) - - for column_args in options[:columns] - column( *column_args ) - end - - end - end - - module MetaMethods - def columns() - @columns ||= [] - end - - def column(name, sql_type = nil, default = nil, null = true) - columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) - reset_column_information - end - - # Do not reset @columns - def reset_column_information - generated_methods.each { |name| undef_method(name) } - @column_names = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = nil - end - end - - module InstanceMethods - def create_or_update - errors.empty? - end - - def saved!(with_id = 1) - self.id = with_id - - def self.new_record? - false - end - end - alias_method :exists!, :saved! - end - - end -end \ No newline at end of file diff --git a/vendor/plugins/active_record_tableless/tasks/active_record_tableless_tasks.rake b/vendor/plugins/active_record_tableless/tasks/active_record_tableless_tasks.rake deleted file mode 100644 index 3402ce6..0000000 --- a/vendor/plugins/active_record_tableless/tasks/active_record_tableless_tasks.rake +++ /dev/null @@ -1,4 +0,0 @@ -# desc "Explaining what the task does" -# task :active_record_tableless do -# # Task goes here -# end diff --git a/vendor/plugins/active_record_tableless/test/active_record_tableless_test.rb b/vendor/plugins/active_record_tableless/test/active_record_tableless_test.rb deleted file mode 100644 index 095f3e5..0000000 --- a/vendor/plugins/active_record_tableless/test/active_record_tableless_test.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'test/unit' -require 'rubygems' -require 'active_record' -require File.dirname(__FILE__) + '/../lib/active_record/tableless' - - - -ActiveRecord::Base.establish_connection( { - :adapter => 'sqlite3', - :database => ":memory:", - :timeout => 500 - -}) - -ActiveRecord::Base.send(:include, ActiveRecord::Tableless) - -class TablelessModel < ActiveRecord::Base - tableless :columns => [ - [:email, :string], - [:password, :string], - [:password_confirmation] ] - - validates_presence_of :email, :password, :password_confirmation - validates_confirmation_of :password - -end - -class ActiveRecordTablelessTest < Test::Unit::TestCase - - def setup - super - @valid_attributes = { - :email => "robin@bogus.com", - :password => "password", - :password_confirmation => "password" - } - end - - def test_create - assert TablelessModel.create(@valid_attributes).valid? - end - - def test_validations - # Just check a few validations to make sure we didn't break ActiveRecord::Validations::ClassMethods - assert_not_nil TablelessModel.create(@valid_attributes.merge(:email => "")).errors[:email] - assert_not_nil TablelessModel.create(@valid_attributes.merge(:password => "")).errors[:password] - assert_not_nil TablelessModel.create(@valid_attributes.merge(:password_confirmation => "")).errors[:password] - end - - def test_save - assert TablelessModel.new(@valid_attributes).save - assert !TablelessModel.new(@valid_attributes.merge(:password => "no_match")).save - end - - def test_valid? - assert TablelessModel.new(@valid_attributes).valid? - assert !TablelessModel.new(@valid_attributes.merge(:password => "no_match")).valid? - end - - - def test_exists! - m = TablelessModel.new(@valid_attributes) - - assert_nil m.id - assert m.new_record? - - m.exists! - assert_equal 1, m.id - assert !m.new_record? - - m.exists!(250) - assert_equal 250, m.id - assert !m.new_record? - end -end diff --git a/vendor/plugins/noosfero_caching/init.rb b/vendor/plugins/noosfero_caching/init.rb index ba951bf..7666181 100644 --- a/vendor/plugins/noosfero_caching/init.rb +++ b/vendor/plugins/noosfero_caching/init.rb @@ -48,8 +48,8 @@ module NoosferoHttpCaching end unless Rails.env.development? - middleware = ActionController::Dispatcher.middleware - cookies_mw = ActionController::Session::CookieStore + middleware = Noosfero::Application.config.middleware + cookies_mw = ActionDispatch::Session::CookieStore ActionController::Base.send(:include, NoosferoHttpCaching) middleware.insert_before(cookies_mw, NoosferoHttpCaching::Middleware) end -- libgit2 0.21.2