Commit 7ba54a9d5840a73c3eb77ef36daa82ad77233282

Authored by Antonio Terceiro
1 parent 92276876

Fix merge problems

At least as far as unit tests are concerned. Still missing:

  - 1 failing test in ArticleTest
  - 1 failing test in PersonTest
app/helpers/application_helper.rb
... ... @@ -1113,12 +1113,12 @@ module ApplicationHelper
1113 1113 end
1114 1114  
1115 1115 def manage_enterprises
1116   - return unless user && user.environment.enabled?(:display_my_enterprises_on_user_menu)
  1116 + return '' unless user && user.environment.enabled?(:display_my_enterprises_on_user_menu)
1117 1117 manage_link(user.enterprises, :enterprises, _('My enterprises')).to_s
1118 1118 end
1119 1119  
1120 1120 def manage_communities
1121   - return unless user && user.environment.enabled?(:display_my_communities_on_user_menu)
  1121 + return '' unless user && user.environment.enabled?(:display_my_communities_on_user_menu)
1122 1122 administered_communities = user.communities.more_popular.select {|c| c.admins.include? user}
1123 1123 manage_link(administered_communities, :communities, _('My communities')).to_s
1124 1124 end
... ...
app/models/article.rb
... ... @@ -645,23 +645,12 @@ class Article < ActiveRecord::Base
645 645 can_display_versions? && display_versions
646 646 end
647 647  
648   - def author(version_number = nil)
649   - if version_number
650   - version = self.versions.find_by_version(version_number)
651   - author_id = version.last_changed_by_id if version
652   - else
653   - author_id = self.created_by_id
654   - end
655   -
656   - environment.people.find_by_id(author_id)
657   - end
658   -
659 648 def get_version(version_number = nil)
660 649 version_number ? versions.find(:first, :order => 'version', :offset => version_number - 1) : versions.earliest
661 650 end
662 651  
663 652 def author_by_version(version_number = nil)
664   - version_number ? profile.environment.people.find_by_id(get_version(version_number).last_changed_by_id) : author
  653 + version_number ? profile.environment.people.find_by_id(get_version(version_number).author_id) : author
665 654 end
666 655  
667 656 def author_name(version_number = nil)
... ...
app/views/shared/content_list.html.erb 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +<table class="<%= list_type %>-content">
  2 + <tr>
  3 + <th><%= _('Title') %></th>
  4 + <th><%= _('Last update') %></th>
  5 + </tr>
  6 + <% contents.each do |content| %>
  7 + <% if content.display_to?(user) %>
  8 + <%= display_content_in_listing :content=>content, :list_type=>list_type, :recursive=>recursive %>
  9 + <% end %>
  10 + <% end %>
  11 +</table>
  12 +
  13 +<p><%= pagination_links contents, :param_name => 'npage', :page_links => true %></p>
... ...
app/views/shared/content_list.rhtml
... ... @@ -1,13 +0,0 @@
1   -<table class="<%= list_type %>-content">
2   - <tr>
3   - <th><%= _('Title') %></th>
4   - <th><%= _('Last update') %></th>
5   - </tr>
6   - <% contents.each do |content| %>
7   - <% if content.display_to?(user) %>
8   - <%= display_content_in_listing :content=>content, :list_type=>list_type, :recursive=>recursive %>
9   - <% end %>
10   - <% end %>
11   -</table>
12   -
13   -<p><%= pagination_links contents, :param_name => 'npage', :page_links => true %></p>
lib/file_presenter.rb
... ... @@ -11,7 +11,7 @@ class FilePresenter
11 11 return f if f.is_a?(FilePresenter ) || (!f.kind_of?(UploadedFile) && !f.kind_of?(Image))
12 12 klass = FilePresenter.subclasses.sort_by {|class_instance|
13 13 class_instance.accepts?(f) || 0
14   - }.last.constantize
  14 + }.last
15 15 klass.accepts?(f) ? klass.new(f) : f
16 16 end
17 17  
... ...
test/unit/application_helper_test.rb
... ... @@ -861,7 +861,7 @@ class ApplicationHelperTest &lt; ActionView::TestCase
861 861  
862 862 stubs(:user).returns(nil)
863 863 expects(:manage_link).with(profile.enterprises, :enterprises, _('My enterprises')).never
864   - assert_nil manage_enterprises
  864 + assert_equal '', manage_enterprises
865 865 end
866 866  
867 867 should 'display enterprises if logged and enabled on environment' do
... ... @@ -885,7 +885,7 @@ class ApplicationHelperTest &lt; ActionView::TestCase
885 885  
886 886 stubs(:user).returns(profile)
887 887 expects(:manage_link).with(profile.enterprises, :enterprises, _('My enterprises')).never
888   - assert_nil manage_enterprises
  888 + assert_equal '', manage_enterprises
889 889 end
890 890  
891 891 should 'not display communities if not logged' do
... ... @@ -897,7 +897,7 @@ class ApplicationHelperTest &lt; ActionView::TestCase
897 897  
898 898 stubs(:user).returns(nil)
899 899 expects(:manage_link).with(profile.communities, :communities, _('My communities')).never
900   - assert_nil manage_communities
  900 + assert_equal '', manage_communities
901 901 end
902 902  
903 903 should 'display communities if logged and enabled on environment' do
... ... @@ -921,7 +921,7 @@ class ApplicationHelperTest &lt; ActionView::TestCase
921 921  
922 922 stubs(:user).returns(profile)
923 923 expects(:manage_link).with(profile.communities, :communities, _('My communities')).never
924   - assert_nil manage_communities
  924 + assert_equal '', manage_communities
925 925 end
926 926  
927 927 protected
... ...
test/unit/article_test.rb
... ... @@ -1789,23 +1789,12 @@ class ArticleTest &lt; ActiveSupport::TestCase
1789 1789 assert_nil article.author_id
1790 1790 end
1791 1791  
1792   - should "return the author of a specific version" do
1793   - author1 = fast_create(Person)
1794   - author2 = fast_create(Person)
1795   - article = create(Article, :name => 'first version', :profile => profile, :created_by => author1, :last_changed_by => author1)
1796   - article.name = 'second version'
1797   - article.last_changed_by = author2
1798   - article.save
1799   - assert_equal author1, article.author_by_version(1)
1800   - assert_equal author2, article.author_by_version(2)
1801   - end
1802   -
1803 1792 should "return the author_name of a specific version" do
1804 1793 author1 = fast_create(Person)
1805 1794 author2 = fast_create(Person)
1806   - article = create(Article, :name => 'first version', :profile => profile, :created_by => author1)
  1795 + article = create(Article, :name => 'first version', :profile => profile, :author => author1)
1807 1796 article.name = 'second version'
1808   - article.last_changed_by = author2
  1797 + article.author = author2
1809 1798 article.save
1810 1799 assert_equal author1.name, article.author_name(1)
1811 1800 assert_equal author2.name, article.author_name(2)
... ... @@ -1877,11 +1866,13 @@ class ArticleTest &lt; ActiveSupport::TestCase
1877 1866 p1 = fast_create(Person)
1878 1867 p2 = fast_create(Person)
1879 1868 p3 = fast_create(Person)
1880   - article = Article.create!(:name => 'first version', :profile => profile, :last_changed_by => p1)
  1869 + article = create(Article, :name => 'first version', :profile => profile, :author => p1)
  1870 +
1881 1871 article.name = 'second version'
1882   - article.last_changed_by = p2
  1872 + article.author = p2
1883 1873 article.save!
1884   - article.last_changed_by = p3
  1874 +
  1875 + article.author = p3
1885 1876 article.name = 'third version'
1886 1877 article.save!
1887 1878  
... ...
test/unit/enterprise_test.rb
... ... @@ -409,13 +409,13 @@ class EnterpriseTest &lt; ActiveSupport::TestCase
409 409 assert_equal products, e1.highlighted_products_with_image
410 410 end
411 411  
412   - should 'has many inputs through products' do
  412 + should 'have many inputs through products' do
413 413 enterprise = fast_create(Enterprise)
414 414 product = fast_create(Product, :profile_id => enterprise.id, :product_category_id => @product_category.id)
415 415 product.inputs << build(Input, :product_category => @product_category)
416 416 product.inputs << build(Input, :product_category => @product_category)
417 417  
418   - assert_equal product.inputs, enterprise.inputs
  418 + assert_equal product.inputs.sort, enterprise.inputs.sort
419 419 end
420 420  
421 421 should "the followed_by? be true only to members" do
... ...