Commit 00d553397e17912ed893d10e909927605416f44c
Exists in
master
and in
22 other branches
Merge branch 'stable'
Showing
15 changed files
with
72 additions
and
44 deletions
Show diff stats
app/controllers/public/contact_controller.rb
app/models/published_article.rb
| ... | ... | @@ -14,10 +14,6 @@ class PublishedArticle < Article |
| 14 | 14 | _('A reference to another article published in another profile') |
| 15 | 15 | end |
| 16 | 16 | |
| 17 | - def body | |
| 18 | - reference_article.body | |
| 19 | - end | |
| 20 | - | |
| 21 | 17 | before_validation_on_create :update_name |
| 22 | 18 | def update_name |
| 23 | 19 | self.name ||= self.reference_article.name |
| ... | ... | @@ -32,6 +28,6 @@ class PublishedArticle < Article |
| 32 | 28 | end |
| 33 | 29 | |
| 34 | 30 | def to_html(options={}) |
| 35 | - reference_article.to_html | |
| 31 | + reference_article ? reference_article.to_html : ('<em>' + _('The original text was removed.') + '</em>') | |
| 36 | 32 | end |
| 37 | 33 | end | ... | ... |
app/sweepers/article_sweeper.rb
| 1 | 1 | class ArticleSweeper < ActiveRecord::Observer |
| 2 | + include SweeperHelper | |
| 2 | 3 | observe :article |
| 3 | 4 | |
| 4 | 5 | def after_save(article) |
| ... | ... | @@ -21,11 +22,4 @@ protected |
| 21 | 22 | end |
| 22 | 23 | end |
| 23 | 24 | |
| 24 | - def expire_fragment(*args) | |
| 25 | - ActionController::Base.new().expire_fragment(*args) | |
| 26 | - end | |
| 27 | - | |
| 28 | - def expire_timeout_fragment(*args) | |
| 29 | - ActionController::Base.new().expire_timeout_fragment(*args) | |
| 30 | - end | |
| 31 | 25 | end | ... | ... |
app/sweepers/friendship_sweeper.rb
| 1 | 1 | class FriendshipSweeper < ActiveRecord::Observer |
| 2 | 2 | observe :friendship |
| 3 | + include SweeperHelper | |
| 3 | 4 | |
| 4 | 5 | def after_create(friendship) |
| 5 | 6 | expire_caches(friendship) |
| ... | ... | @@ -26,7 +27,4 @@ protected |
| 26 | 27 | blocks.map(&:cache_keys).each{|ck|expire_timeout_fragment(ck)} |
| 27 | 28 | end |
| 28 | 29 | |
| 29 | - def expire_timeout_fragment(*args) | |
| 30 | - ActionController::Base.new().expire_timeout_fragment(*args) | |
| 31 | - end | |
| 32 | 30 | end | ... | ... |
app/sweepers/role_assignment_sweeper.rb
| 1 | 1 | class RoleAssignmentSweeper < ActiveRecord::Observer |
| 2 | 2 | observe :role_assignment |
| 3 | + include SweeperHelper | |
| 3 | 4 | |
| 4 | 5 | def after_create(role_assignment) |
| 5 | 6 | expire_caches(role_assignment) |
| ... | ... | @@ -28,7 +29,4 @@ protected |
| 28 | 29 | } |
| 29 | 30 | end |
| 30 | 31 | |
| 31 | - def expire_timeout_fragment(*args) | |
| 32 | - ActionController::Base.new().expire_timeout_fragment(*args) | |
| 33 | - end | |
| 34 | 32 | end | ... | ... |
app/views/layouts/application.rhtml
| ... | ... | @@ -87,7 +87,7 @@ |
| 87 | 87 | :id=>"menu_link_to_envhome", |
| 88 | 88 | :title=>@environment.name %> |
| 89 | 89 | <% unless environment.enabled?(:disable_categories) %> |
| 90 | - <% cache(:controller => 'public', :action => 'categories_menu') do %> | |
| 90 | + <% cache(environment.name + '_categories_menu') do %> | |
| 91 | 91 | <%= render :file => 'shared/categories_menu' %> |
| 92 | 92 | <% end %> |
| 93 | 93 | <% end %> | ... | ... |
app/views/shared/tiny_mce.rhtml
| ... | ... | @@ -23,7 +23,8 @@ tinyMCE.init({ |
| 23 | 23 | paste_use_dialog: false, |
| 24 | 24 | apply_source_formatting : true, |
| 25 | 25 | content_css: '/stylesheets/tinymce.css', |
| 26 | - language: <%= tinymce_language.inspect %> | |
| 26 | + language: <%= tinymce_language.inspect %>, | |
| 27 | + cleanup_callback : "customCleanup" | |
| 27 | 28 | }); |
| 28 | 29 | |
| 29 | 30 | function convertWord(type, content) { |
| ... | ... | @@ -41,8 +42,17 @@ function convertWord(type, content) { |
| 41 | 42 | |
| 42 | 43 | return content; |
| 43 | 44 | } |
| 44 | -</script> | |
| 45 | - | |
| 46 | - | |
| 47 | 45 | |
| 46 | +function customCleanup(type, value) { | |
| 47 | + switch (type) { | |
| 48 | + case "get_from_editor": | |
| 49 | + value = value.replace(/&amp;/g,"&"); | |
| 50 | + break; | |
| 51 | + case "insert_to_editor": | |
| 52 | + value = value.replace(/&amp;/g,"&"); | |
| 53 | + break; | |
| 54 | + } | |
| 55 | + return value; | |
| 56 | +} | |
| 48 | 57 | |
| 58 | +</script> | ... | ... |
config/environment.rb
| ... | ... | @@ -67,7 +67,7 @@ Rails::Initializer.run do |config| |
| 67 | 67 | |
| 68 | 68 | # don't load the sweepers while loading the database |
| 69 | 69 | unless $PROGRAM_NAME =~ /rake$/ && ARGV.first == 'db:schema:load' |
| 70 | - config.active_record.observers = :article_sweeper, :role_assignment_sweeper, :friendship_sweeper | |
| 70 | + config.active_record.observers = :article_sweeper, :role_assignment_sweeper, :friendship_sweeper, :category_sweeper | |
| 71 | 71 | end |
| 72 | 72 | # Make Active Record use UTC-base instead of local time |
| 73 | 73 | # config.active_record.default_timezone = :utc | ... | ... |
db/schema.rb
| ... | ... | @@ -89,15 +89,16 @@ ActiveRecord::Schema.define(:version => 69) do |
| 89 | 89 | t.boolean "virtual", :default => false |
| 90 | 90 | end |
| 91 | 91 | |
| 92 | - add_index "articles_categories", ["article_id"], :name => "index_articles_categories_on_article_id" | |
| 93 | 92 | add_index "articles_categories", ["category_id"], :name => "index_articles_categories_on_category_id" |
| 93 | + add_index "articles_categories", ["article_id"], :name => "index_articles_categories_on_article_id" | |
| 94 | 94 | |
| 95 | 95 | create_table "blocks", :force => true do |t| |
| 96 | - t.string "title" | |
| 97 | - t.integer "box_id" | |
| 98 | - t.string "type" | |
| 99 | - t.text "settings" | |
| 100 | - t.integer "position" | |
| 96 | + t.string "title" | |
| 97 | + t.integer "box_id" | |
| 98 | + t.string "type" | |
| 99 | + t.text "settings" | |
| 100 | + t.integer "position" | |
| 101 | + t.datetime "last_updated" | |
| 101 | 102 | end |
| 102 | 103 | |
| 103 | 104 | add_index "blocks", ["box_id"], :name => "index_blocks_on_box_id" |
| ... | ... | @@ -169,13 +170,13 @@ ActiveRecord::Schema.define(:version => 69) do |
| 169 | 170 | |
| 170 | 171 | create_table "external_feeds", :force => true do |t| |
| 171 | 172 | t.string "feed_title" |
| 172 | - t.date "fetched_at" | |
| 173 | 173 | t.string "address" |
| 174 | 174 | t.integer "blog_id", :null => false |
| 175 | 175 | t.boolean "enabled", :default => true, :null => false |
| 176 | 176 | t.boolean "only_once", :default => true, :null => false |
| 177 | 177 | t.datetime "created_at" |
| 178 | 178 | t.datetime "updated_at" |
| 179 | + t.datetime "fetched_at" | |
| 179 | 180 | end |
| 180 | 181 | |
| 181 | 182 | create_table "favorite_enteprises_people", :id => false, :force => true do |t| |
| ... | ... | @@ -290,8 +291,8 @@ ActiveRecord::Schema.define(:version => 69) do |
| 290 | 291 | t.datetime "created_at" |
| 291 | 292 | end |
| 292 | 293 | |
| 293 | - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" | |
| 294 | 294 | add_index "taggings", ["taggable_id", "taggable_type"], :name => "index_taggings_on_taggable_id_and_taggable_type" |
| 295 | + add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" | |
| 295 | 296 | |
| 296 | 297 | create_table "tags", :force => true do |t| |
| 297 | 298 | t.string "name" | ... | ... |
lib/noosfero.rb
test/functional/contact_controller_test.rb
| ... | ... | @@ -15,6 +15,8 @@ class ContactControllerTest < Test::Unit::TestCase |
| 15 | 15 | |
| 16 | 16 | @profile = create_user('contact_test_user').person |
| 17 | 17 | @enterprise = Enterprise.create!(:identifier => 'contact_test_enterprise', :name => 'Test contact enteprise') |
| 18 | + | |
| 19 | + login_as('contact_test_user') | |
| 18 | 20 | end |
| 19 | 21 | attr_reader :profile, :enterprise |
| 20 | 22 | |
| ... | ... | @@ -50,13 +52,11 @@ class ContactControllerTest < Test::Unit::TestCase |
| 50 | 52 | end |
| 51 | 53 | |
| 52 | 54 | should 'fill email if user logged in' do |
| 53 | - login_as(profile.identifier) | |
| 54 | 55 | get :new, :profile => enterprise.identifier |
| 55 | 56 | assert_tag :tag => 'input', :attributes => {:name => 'contact[email]', :value => profile.email} |
| 56 | 57 | end |
| 57 | 58 | |
| 58 | 59 | should 'fill name if user logged in' do |
| 59 | - login_as(profile.identifier) | |
| 60 | 60 | get :new, :profile => enterprise.identifier |
| 61 | 61 | assert_tag :tag => 'input', :attributes => {:name => 'contact[name]', :value => profile.name} |
| 62 | 62 | end |
| ... | ... | @@ -111,5 +111,11 @@ class ContactControllerTest < Test::Unit::TestCase |
| 111 | 111 | assert_response :success |
| 112 | 112 | assert_template 'new' |
| 113 | 113 | end |
| 114 | - | |
| 114 | + | |
| 115 | + should 'not allow if not logged' do | |
| 116 | + logout | |
| 117 | + get :new, :profile => profile.identifier | |
| 118 | + assert_response :redirect | |
| 119 | + assert_redirected_to :controller => 'account', :action => 'login' | |
| 120 | + end | |
| 115 | 121 | end | ... | ... |
test/integration/categories_menu_test.rb
| ... | ... | @@ -35,7 +35,7 @@ class CategoriesMenuTest < ActionController::IntegrationTest |
| 35 | 35 | end |
| 36 | 36 | |
| 37 | 37 | should 'cache the categories menu' do |
| 38 | - ActionView::Base.any_instance.expects(:cache).with(:controller => 'public', :action => 'categories_menu') | |
| 38 | + ActionView::Base.any_instance.expects(:cache).with(Environment.default.name + "_categories_menu") | |
| 39 | 39 | get '/' |
| 40 | 40 | end |
| 41 | 41 | ... | ... |
test/unit/published_article_test.rb
| ... | ... | @@ -17,13 +17,6 @@ class PublishedArticleTest < ActiveSupport::TestCase |
| 17 | 17 | assert_equal @article, p.reference_article |
| 18 | 18 | end |
| 19 | 19 | |
| 20 | - should 'have same content as reference article' do | |
| 21 | - prof = Community.create!(:name => 'test_comm', :identifier => 'test_comm') | |
| 22 | - p = PublishedArticle.create(:reference_article => @article, :profile => prof) | |
| 23 | - | |
| 24 | - assert_equal @article.body, p.body | |
| 25 | - end | |
| 26 | - | |
| 27 | 20 | should 'have a different name than reference article' do |
| 28 | 21 | prof = Community.create!(:name => 'test_comm', :identifier => 'test_comm') |
| 29 | 22 | p = PublishedArticle.create(:reference_article => @article, :profile => prof, :name => 'other title') |
| ... | ... | @@ -107,4 +100,14 @@ class PublishedArticleTest < ActiveSupport::TestCase |
| 107 | 100 | |
| 108 | 101 | assert_equal textile_article.to_html, p.to_html |
| 109 | 102 | end |
| 103 | + | |
| 104 | + should 'display message when reference_article does not exist' do | |
| 105 | + prof = Community.create!(:name => 'test_comm', :identifier => 'test_comm') | |
| 106 | + textile_article = TextileArticle.new(:name => 'textile_article', :body => '*my text*', :profile => prof) | |
| 107 | + p = PublishedArticle.create!(:reference_article => textile_article, :profile => prof) | |
| 108 | + textile_article.destroy | |
| 109 | + p.reload | |
| 110 | + | |
| 111 | + assert_match /removed/, p.to_html | |
| 112 | + end | |
| 110 | 113 | end | ... | ... |