diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ca40533..d41ab2a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1113,12 +1113,12 @@ module ApplicationHelper end def manage_enterprises - return unless user && user.environment.enabled?(:display_my_enterprises_on_user_menu) + return '' unless user && user.environment.enabled?(:display_my_enterprises_on_user_menu) manage_link(user.enterprises, :enterprises, _('My enterprises')).to_s end def manage_communities - return unless user && user.environment.enabled?(:display_my_communities_on_user_menu) + return '' unless user && user.environment.enabled?(:display_my_communities_on_user_menu) administered_communities = user.communities.more_popular.select {|c| c.admins.include? user} manage_link(administered_communities, :communities, _('My communities')).to_s end diff --git a/app/models/article.rb b/app/models/article.rb index 3d328ba..49ce5f4 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -645,23 +645,12 @@ class Article < ActiveRecord::Base can_display_versions? && display_versions end - def author(version_number = nil) - if version_number - version = self.versions.find_by_version(version_number) - author_id = version.last_changed_by_id if version - else - author_id = self.created_by_id - end - - environment.people.find_by_id(author_id) - end - def get_version(version_number = nil) version_number ? versions.find(:first, :order => 'version', :offset => version_number - 1) : versions.earliest end def author_by_version(version_number = nil) - version_number ? profile.environment.people.find_by_id(get_version(version_number).last_changed_by_id) : author + version_number ? profile.environment.people.find_by_id(get_version(version_number).author_id) : author end def author_name(version_number = nil) diff --git a/app/views/shared/content_list.html.erb b/app/views/shared/content_list.html.erb new file mode 100644 index 0000000..3abfbe3 --- /dev/null +++ b/app/views/shared/content_list.html.erb @@ -0,0 +1,13 @@ + + + + + + <% contents.each do |content| %> + <% if content.display_to?(user) %> + <%= display_content_in_listing :content=>content, :list_type=>list_type, :recursive=>recursive %> + <% end %> + <% end %> +
<%= _('Title') %><%= _('Last update') %>
+ +

<%= pagination_links contents, :param_name => 'npage', :page_links => true %>

diff --git a/app/views/shared/content_list.rhtml b/app/views/shared/content_list.rhtml deleted file mode 100644 index 3abfbe3..0000000 --- a/app/views/shared/content_list.rhtml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - <% contents.each do |content| %> - <% if content.display_to?(user) %> - <%= display_content_in_listing :content=>content, :list_type=>list_type, :recursive=>recursive %> - <% end %> - <% end %> -
<%= _('Title') %><%= _('Last update') %>
- -

<%= pagination_links contents, :param_name => 'npage', :page_links => true %>

diff --git a/lib/file_presenter.rb b/lib/file_presenter.rb index b542a4f..2ef620e 100644 --- a/lib/file_presenter.rb +++ b/lib/file_presenter.rb @@ -11,7 +11,7 @@ class FilePresenter return f if f.is_a?(FilePresenter ) || (!f.kind_of?(UploadedFile) && !f.kind_of?(Image)) klass = FilePresenter.subclasses.sort_by {|class_instance| class_instance.accepts?(f) || 0 - }.last.constantize + }.last klass.accepts?(f) ? klass.new(f) : f end diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index aba57c5..f244b15 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -861,7 +861,7 @@ class ApplicationHelperTest < ActionView::TestCase stubs(:user).returns(nil) expects(:manage_link).with(profile.enterprises, :enterprises, _('My enterprises')).never - assert_nil manage_enterprises + assert_equal '', manage_enterprises end should 'display enterprises if logged and enabled on environment' do @@ -885,7 +885,7 @@ class ApplicationHelperTest < ActionView::TestCase stubs(:user).returns(profile) expects(:manage_link).with(profile.enterprises, :enterprises, _('My enterprises')).never - assert_nil manage_enterprises + assert_equal '', manage_enterprises end should 'not display communities if not logged' do @@ -897,7 +897,7 @@ class ApplicationHelperTest < ActionView::TestCase stubs(:user).returns(nil) expects(:manage_link).with(profile.communities, :communities, _('My communities')).never - assert_nil manage_communities + assert_equal '', manage_communities end should 'display communities if logged and enabled on environment' do @@ -921,7 +921,7 @@ class ApplicationHelperTest < ActionView::TestCase stubs(:user).returns(profile) expects(:manage_link).with(profile.communities, :communities, _('My communities')).never - assert_nil manage_communities + assert_equal '', manage_communities end protected diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 706b773..4489fb2 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -1789,23 +1789,12 @@ class ArticleTest < ActiveSupport::TestCase assert_nil article.author_id end - should "return the author of a specific version" do - author1 = fast_create(Person) - author2 = fast_create(Person) - article = create(Article, :name => 'first version', :profile => profile, :created_by => author1, :last_changed_by => author1) - article.name = 'second version' - article.last_changed_by = author2 - article.save - assert_equal author1, article.author_by_version(1) - assert_equal author2, article.author_by_version(2) - end - should "return the author_name of a specific version" do author1 = fast_create(Person) author2 = fast_create(Person) - article = create(Article, :name => 'first version', :profile => profile, :created_by => author1) + article = create(Article, :name => 'first version', :profile => profile, :author => author1) article.name = 'second version' - article.last_changed_by = author2 + article.author = author2 article.save assert_equal author1.name, article.author_name(1) assert_equal author2.name, article.author_name(2) @@ -1877,11 +1866,13 @@ class ArticleTest < ActiveSupport::TestCase p1 = fast_create(Person) p2 = fast_create(Person) p3 = fast_create(Person) - article = Article.create!(:name => 'first version', :profile => profile, :last_changed_by => p1) + article = create(Article, :name => 'first version', :profile => profile, :author => p1) + article.name = 'second version' - article.last_changed_by = p2 + article.author = p2 article.save! - article.last_changed_by = p3 + + article.author = p3 article.name = 'third version' article.save! diff --git a/test/unit/enterprise_test.rb b/test/unit/enterprise_test.rb index 95daf9b..e8ddea4 100644 --- a/test/unit/enterprise_test.rb +++ b/test/unit/enterprise_test.rb @@ -409,13 +409,13 @@ class EnterpriseTest < ActiveSupport::TestCase assert_equal products, e1.highlighted_products_with_image end - should 'has many inputs through products' do + should 'have many inputs through products' do enterprise = fast_create(Enterprise) product = fast_create(Product, :profile_id => enterprise.id, :product_category_id => @product_category.id) product.inputs << build(Input, :product_category => @product_category) product.inputs << build(Input, :product_category => @product_category) - assert_equal product.inputs, enterprise.inputs + assert_equal product.inputs.sort, enterprise.inputs.sort end should "the followed_by? be true only to members" do -- libgit2 0.21.2