From fcc76897b6e613c8d8e5c0a9a23e75fc8e3b61b3 Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Thu, 8 Nov 2007 20:53:44 +0000 Subject: [PATCH] ActionItem114: fixed some integration errors and the integration tests --- app/controllers/environment_admin/admin_panel_controller.rb | 2 ++ app/controllers/profile_admin/cms_controller.rb | 6 +++++- app/controllers/public/account_controller.rb | 2 +- app/views/profile_editor/index.rhtml | 2 -- test/integration/enable_disable_features_test.rb | 4 ++-- test/integration/manage_documents_test.rb | 6 +----- test/integration/signup_test.rb | 4 ++-- test/integration/user_registers_at_the_application_test.rb | 3 +-- test/test_helper.rb | 2 +- 9 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/controllers/environment_admin/admin_panel_controller.rb b/app/controllers/environment_admin/admin_panel_controller.rb index fbff437..e86ed9b 100644 --- a/app/controllers/environment_admin/admin_panel_controller.rb +++ b/app/controllers/environment_admin/admin_panel_controller.rb @@ -1,5 +1,7 @@ class AdminPanelController < EnvironmentAdminController + before_filter :login_required + protect 'view_environment_admin_panel', :environment #FIXME This is not necessary because the application controller define the envrioment diff --git a/app/controllers/profile_admin/cms_controller.rb b/app/controllers/profile_admin/cms_controller.rb index 7cabe4d..f385fe5 100644 --- a/app/controllers/profile_admin/cms_controller.rb +++ b/app/controllers/profile_admin/cms_controller.rb @@ -1,6 +1,6 @@ class CmsController < Comatose::AdminController include PermissionCheck - + include AuthenticatedSystem define_option :page_class, Article @@ -12,4 +12,8 @@ class CmsController < Comatose::AdminController def profile Profile.find_by_identifier(params[:profile]) end + + def user + current_user.person + end end diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index ce6a303..f6fa00b 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -41,7 +41,7 @@ class AccountController < PublicController self.current_user = @user owner_role = Role.find_by_name('owner') @user.person.affiliate(@user.person, [owner_role]) if owner_role - redirect_back_or_default(homepage_path(:profile => current_user.login)) + redirect_back_or_default(myprofile_path(:controller => 'profile_editor', :profile => current_user.login)) flash[:notice] = _("Thanks for signing up!") end rescue ActiveRecord::RecordInvalid diff --git a/app/views/profile_editor/index.rhtml b/app/views/profile_editor/index.rhtml index ffc5753..ef21fe7 100644 --- a/app/views/profile_editor/index.rhtml +++ b/app/views/profile_editor/index.rhtml @@ -10,8 +10,6 @@ <% end %> - diff --git a/test/integration/enable_disable_features_test.rb b/test/integration/enable_disable_features_test.rb index 498edc6..3a83c78 100644 --- a/test/integration/enable_disable_features_test.rb +++ b/test/integration/enable_disable_features_test.rb @@ -1,11 +1,11 @@ require "#{File.dirname(__FILE__)}/../test_helper" class EnableDisableFeaturesTest < ActionController::IntegrationTest - fixtures :domains, :environments, :users, :profiles + all_fixtures def test_enable_features uses_host 'anhetegua.net' - login 'johndoe', 'test' + login 'ze', 'test' get '/admin/features' assert_response :success diff --git a/test/integration/manage_documents_test.rb b/test/integration/manage_documents_test.rb index ea56433..9d8cbda 100644 --- a/test/integration/manage_documents_test.rb +++ b/test/integration/manage_documents_test.rb @@ -2,17 +2,13 @@ require "#{File.dirname(__FILE__)}/../test_helper" class ManageDocumentsTest < ActionController::IntegrationTest - fixtures :users, :profiles, :comatose_pages, :domains, :environments + all_fixtures def test_creation_of_a_new_article count = Article.count login('ze', 'test') - assert_tag :tag => 'a', :attributes => { :href => '/account' } - get '/account' - assert_response :success - assert_tag :tag => 'a', :attributes => { :href => '/myprofile/ze/cms' } get '/myprofile/ze/cms' diff --git a/test/integration/signup_test.rb b/test/integration/signup_test.rb index 14bd878..259abb7 100644 --- a/test/integration/signup_test.rb +++ b/test/integration/signup_test.rb @@ -1,10 +1,10 @@ require "#{File.dirname(__FILE__)}/../test_helper" class AccountTest < ActionController::IntegrationTest - fixtures :users, :profiles, :domains, :environments + all_fixtures def test_should_require_acceptance_of_terms_for_signup - Environment.default.update_attributes(:terms_of_use => 'You agree that from now on your soul belongs to us.') + Environment.default.update_attributes(:terms_of_use => 'You agree to not be annoying.') count = User.count diff --git a/test/integration/user_registers_at_the_application_test.rb b/test/integration/user_registers_at_the_application_test.rb index ccdfffa..1c42c7a 100644 --- a/test/integration/user_registers_at_the_application_test.rb +++ b/test/integration/user_registers_at_the_application_test.rb @@ -3,7 +3,6 @@ require "#{File.dirname(__FILE__)}/../test_helper" class UserRegistersAtTheApplicationTest < ActionController::IntegrationTest fixtures :users, :environments, :profiles - # Replace this with your real tests. def test_successfull_registration get '/' assert_tag :tag => 'span', :attributes => { :id => 'register_box' } @@ -13,7 +12,7 @@ class UserRegistersAtTheApplicationTest < ActionController::IntegrationTest post '/account/signup', :user => { :login => 'mylogin', :password => 'mypassword', :password_confirmation => 'mypassword', :email => 'mylogin@example.com' } assert_response :redirect - assert_redirected_to '/account' + assert_redirected_to myprofile_path(:controller => 'profile_editor', :profile => 'mylogin') # user is logged in right after the registration follow_redirect! diff --git a/test/test_helper.rb b/test/test_helper.rb index be036c0..758ff0f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -91,6 +91,6 @@ class ActionController::IntegrationTest post '/account/login', :login => username, :password => password assert_response :redirect follow_redirect! - assert_equal myprofile_path(:controller => 'profile_editor', :profile => username), path + assert_not_equal '/account/login', path end end -- libgit2 0.21.2