diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 7268a8a..11bcbc2 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -72,4 +72,13 @@ class AccountController < ApplicationController end end + protected + + before_filter :load_profile_for_user + def load_profile_for_user + return unless logged_in? + @profile = current_user.person + end + + end diff --git a/test/fixtures/comatose_pages.yml b/test/fixtures/comatose_pages.yml index 0526cc5..8222f13 100644 --- a/test/fixtures/comatose_pages.yml +++ b/test/fixtures/comatose_pages.yml @@ -2,20 +2,24 @@ root: id: 1 title: Root page slug: + type: Article ze: id: 2 title: Ze homepage slug: ze full_path: 'ze' + type: Article ze_curriculum: id: 3 title: Ze curriculum parent_id: 2 slug: curriculum full_path: 'ze/curriculum' + type: Article ze_contact: id: 4 title: Ze contact info parent_id: 2 slug: contact full_path: 'ze/contact' + type: Article diff --git a/test/integration/manage_documents_test.rb b/test/integration/manage_documents_test.rb new file mode 100644 index 0000000..8b7ef32 --- /dev/null +++ b/test/integration/manage_documents_test.rb @@ -0,0 +1,62 @@ +require "#{File.dirname(__FILE__)}/../test_helper" + +class ManageDocumentsTest < ActionController::IntegrationTest + + fixtures :users, :profiles, :comatose_pages, :domains, :virtual_communities + + def test_creation_of_a_new_article + count = Article.count + + login('ze', 'test') + + get '/cms/ze' + assert_response :success + + get '/cms/ze/new' + assert_response :success + assert_tag :tag => 'form', :attributes => { :action => '/cms/ze/new' } + + post '/cms/ze/new', :page => { :title => 'my new article', :body => 'this is the text of my new article' , :parent_id => Article.find_by_path('ze').id } + assert_response :redirect + + follow_redirect! + assert_response :success + + assert_equal count + 1, Article.count + + end + + def test_update_of_an_existing_article + login('ze', 'test') + + get '/cms/ze' + assert_response :success + + id = Comatose::Page.find_by_path('ze').id + get "cms/ze/edit/#{id}" + assert_response :success + assert_tag :tag => 'form', :attributes => { :action => "/cms/ze/edit/#{id}" } + + post "cms/ze/edit/#{id}", :page => { :body => 'changed_body' } + assert_response :redirect + + end + + def test_removing_an_article + article = Article.create!(:title => 'to be removed', :body => 'go to hell', :parent_id => Article.find_by_path('ze').id) + count = Article.count + + get '/cms/ze' + assert_response :success + + post "/cms/ze/delete/#{article.id}" + assert_response :redirect + + assert_raise ActiveRecord::RecordNotFound do + Article.find(article.id) + end + end + + # FIXME: add tests for page reordering + +end -- libgit2 0.21.2