Issue #45
Remover dos models todo o código que gere HTML ou URL
-
Milestone changed to [backend] Adaptações no backend do Noosfero
-
Removi o método &content() de todos os blocos e movi a implementação deles para arquivos de views em app/views/blocks/.
Estou corrigindo os testes unitários, por hora ainda temos os seguintes testes falhando:
FAIL["test_should_support_environment_as_block_owner", CommunitiesBlockTest, 152.404600641] test_should_support_environment_as_block_owner#CommunitiesBlockTest (152.40s) unexpected invocation: #<CommunitiesBlockTest:0x144c20c0>.render(:file => 'blocks/communities_footer', :locals => {:owner => #<Environment:0x144e1f60>, :suggestions => nil}) unsatisfied expectations: - expected exactly once, not yet invoked: #<CommunitiesBlockTest:0x144c20c0>.render(:file => 'blocks/communities', :locals => {:owner => #<Environment:0x144e1f60>, :suggestions => nil}) satisfied expectations: - expected at least once, invoked 3 times: #<CommunitiesBlock:0x144e1ad8>.owner(any_parameters) app/models/communities_block.rb:35:in `block in footer' test/unit/communities_block_test.rb:46:in `instance_eval' test/unit/communities_block_test.rb:46:in `block in <class:CommunitiesBlockTest>' FAIL["test_should_support_profile_as_block_owner", CommunitiesBlockTest, 152.578664259] test_should_support_profile_as_block_owner#CommunitiesBlockTest (152.58s) unexpected invocation: #<CommunitiesBlockTest:0x2a9f248>.render(:file => 'blocks/communities_footer', :locals => {:owner => Profile//, :suggestions => #<ProfileSuggestion::ActiveRecord_AssociationRelation:0x4926b58>}) unsatisfied expectations: - expected exactly once, not yet invoked: #<CommunitiesBlockTest:0x2a9f248>.render(:file => 'blocks/communities', :locals => {:owner => Profile//, :suggestions => #<ProfileSuggestion::ActiveRecord_AssociationRelation:0x4129d60>}) satisfied expectations: - expected at least once, invoked 5 times: #<CommunitiesBlock:0x27e2898>.owner(any_parameters) app/models/communities_block.rb:35:in `block in footer' test/unit/communities_block_test.rb:37:in `instance_eval' test/unit/communities_block_test.rb:37:in `block in <class:CommunitiesBlockTest>' ERROR["test_should_link_to_documents", RecentDocumentsBlockTest, 177.520805824] test_should_link_to_documents#RecentDocumentsBlockTest (177.52s) TypeError: TypeError: wrong argument type String (expected Proc) test/unit/recent_documents_block_test.rb:46:in `block in <class:RecentDocumentsBlockTest>' ERROR["test_should_list_amount_native_posts_by_month", BlogArchivesBlockTest, 189.146102266] test_should_list_amount_native_posts_by_month#BlogArchivesBlockTest (189.15s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/blog_archives_block_test.rb:134:in `block in <class:BlogArchivesBlockTest>' ERROR["test_should_list_amount_native_posts_by_year", BlogArchivesBlockTest, 189.317455662] test_should_list_amount_native_posts_by_year#BlogArchivesBlockTest (189.32s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/blog_archives_block_test.rb:118:in `block in <class:BlogArchivesBlockTest>' ERROR["test_should_list_amount_posts_by_month", BlogArchivesBlockTest, 189.608025966] test_should_list_amount_posts_by_month#BlogArchivesBlockTest (189.61s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/blog_archives_block_test.rb:41:in `block in <class:BlogArchivesBlockTest>' ERROR["test_should_list_amount_posts_by_year", BlogArchivesBlockTest, 189.910763343] test_should_list_amount_posts_by_year#BlogArchivesBlockTest (189.91s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/blog_archives_block_test.rb:29:in `block in <class:BlogArchivesBlockTest>' ERROR["test_should_not_display_any_content_if_has_no_blog", BlogArchivesBlockTest, 190.51974792] test_should_not_display_any_content_if_has_no_blog#BlogArchivesBlockTest (190.52s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/blog_archives_block_test.rb:83:in `block in <class:BlogArchivesBlockTest>' ERROR["test_should_order_list_of_amount_posts", BlogArchivesBlockTest, 190.977743077] test_should_order_list_of_amount_posts#BlogArchivesBlockTest (190.98s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/blog_archives_block_test.rb:52:in `block in <class:BlogArchivesBlockTest>' ERROR["test_should_order_months_from_later_to_former", BlogArchivesBlockTest, 191.216284937] test_should_order_months_from_later_to_former#BlogArchivesBlockTest (191.22s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/blog_archives_block_test.rb:76:in `block in <class:BlogArchivesBlockTest>' ERROR["test_should_order_years", BlogArchivesBlockTest, 191.543962999] test_should_order_years#BlogArchivesBlockTest (191.54s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/blog_archives_block_test.rb:66:in `block in <class:BlogArchivesBlockTest>' ERROR["test_should_show_posts_from_first_blog", BlogArchivesBlockTest, 192.165452376] test_should_show_posts_from_first_blog#BlogArchivesBlockTest (192.17s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/blog_archives_block_test.rb:101:in `block in <class:BlogArchivesBlockTest>' ERROR["test_should_list_in_random_order", SlideshowBlockTest, 192.206024601] test_should_list_in_random_order#SlideshowBlockTest (192.21s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/slideshow_block_test.rb:45:in `block in <class:SlideshowBlockTest>' ERROR["test_should_list_in_the_same_order", SlideshowBlockTest, 192.21271488] test_should_list_in_the_same_order#SlideshowBlockTest (192.21s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/slideshow_block_test.rb:33:in `block in <class:SlideshowBlockTest>' ERROR["test_should_display_feature_products_block", FeaturedProductsBlockTest, 210.465739303] test_should_display_feature_products_block#FeaturedProductsBlockTest (210.47s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/featured_products_block_test.rb:111:in `block in <class:FeaturedProductsBlockTest>' FAIL["test_should_display_no_localization_map_without_lat", LocationBlockTest, 211.116296087] test_should_display_no_localization_map_without_lat#LocationBlockTest (211.12s) expected tag {:tag=>"i"}, but not found in "This is block number 6741" /usr/lib/ruby/vendor_ruby/minitest/assertions.rb:130:in `assert' test/test_helper.rb:121:in `assert_tag_in_string' test/unit/location_block_test.rb:21:in `block in <class:LocationBlockTest>' FAIL["test_should_use_google_maps_api_v3_with_ssl", LocationBlockTest, 211.18723629] test_should_use_google_maps_api_v3_with_ssl#LocationBlockTest (211.19s) Expected /https:\/\/maps\.google\.com\/maps\/api\/staticmap/ to match "This is block number 6745". /usr/lib/ruby/vendor_ruby/minitest/assertions.rb:130:in `assert' /usr/lib/ruby/vendor_ruby/minitest/assertions.rb:228:in `assert_match' test/unit/location_block_test.rb:36:in `block in <class:LocationBlockTest>' FAIL["test_should_display_error_message_as_content_when_it_s_the_case", FeedReaderBlockTest, 223.195785114] test_should_display_error_message_as_content_when_it_s_the_case#FeedReaderBlockTest (223.20s) Expected /there\ was\ a\ problem/ to match "This is block number 6989". /usr/lib/ruby/vendor_ruby/minitest/assertions.rb:130:in `assert' /usr/lib/ruby/vendor_ruby/minitest/assertions.rb:228:in `assert_match' test/unit/feed_reader_block_test.rb:110:in `block in <class:FeedReaderBlockTest>' FAIL["test_should_display_feed_posts_from_content", FeedReaderBlockTest, 223.201566997] test_should_display_feed_posts_from_content#FeedReaderBlockTest (223.20s) expected tag {:tag=>"h3", :content=>"Feed for unit tests"}, but not found in "This is block number 6990" /usr/lib/ruby/vendor_ruby/minitest/assertions.rb:130:in `assert' test/test_helper.rb:121:in `assert_tag_in_string' test/unit/feed_reader_block_test.rb:36:in `block in <class:FeedReaderBlockTest>' ERROR["test_should_display_only_limit_posts", FeedReaderBlockTest, 223.216558981] test_should_display_only_limit_posts#FeedReaderBlockTest (223.22s) NoMethodError: NoMethodError: undefined method `formatted_feed_content' for #<FeedReaderBlock:0x00000016b46930> /usr/lib/ruby/vendor_ruby/active_model/attribute_methods.rb:433:in `method_missing' test/unit/feed_reader_block_test.rb:99:in `block in <class:FeedReaderBlockTest>' ERROR["test_should_display_empty_title_if_title_is_blank", ArticleBlockTest, 257.462696253] test_should_display_empty_title_if_title_is_blank#ArticleBlockTest (257.46s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/article_block_test.rb:95:in `block in <class:ArticleBlockTest>' ERROR["test_should_display_image_if_article_is_an_image", ArticleBlockTest, 257.525475159] test_should_display_image_if_article_is_an_image#ArticleBlockTest (257.53s) TypeError: TypeError: wrong argument type String (expected Proc) test/unit/article_block_test.rb:116:in `block in <class:ArticleBlockTest>' ERROR["test_should_display_link_to_archive_if_article_is_an_archive", ArticleBlockTest, 257.605240426] test_should_display_link_to_archive_if_article_is_an_archive#ArticleBlockTest (257.61s) TypeError: TypeError: wrong argument type String (expected Proc) test/unit/article_block_test.rb:143:in `block in <class:ArticleBlockTest>' ERROR["test_should_display_title_if_defined", ArticleBlockTest, 257.940815954] test_should_display_title_if_defined#ArticleBlockTest (257.94s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/article_block_test.rb:105:in `block in <class:ArticleBlockTest>' ERROR["test_should_not_display_gallery_pages_navigation_in_content", ArticleBlockTest, 258.137371367] test_should_not_display_gallery_pages_navigation_in_content#ArticleBlockTest (258.14s) TypeError: TypeError: wrong argument type String (expected Proc) test/unit/article_block_test.rb:132:in `block in <class:ArticleBlockTest>' ERROR["test_should_take_article_s_content", ArticleBlockTest, 258.207059529] test_should_take_article_s_content#ArticleBlockTest (258.21s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/article_block_test.rb:16:in `block in <class:ArticleBlockTest>' ERROR["test_should_display_the_default_minor_image_if_thumbnails_were_not_processed", ProductsBlockTest, 265.842762721] test_should_display_the_default_minor_image_if_thumbnails_were_not_processed#ProductsBlockTest (265.84s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/products_block_test.rb:143:in `block in <class:ProductsBlockTest>' ERROR["test_should_display_the_thumbnail_image_if_thumbnails_were_processed", ProductsBlockTest, 266.233235609] test_should_display_the_thumbnail_image_if_thumbnails_were_processed#ProductsBlockTest (266.23s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/products_block_test.rb:155:in `block in <class:ProductsBlockTest>' ERROR["test_should_list_owner_products", ProductsBlockTest, 267.062347423] test_should_list_owner_products#ProductsBlockTest (267.06s) TypeError: TypeError: can't convert nil into Integer /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' /usr/lib/ruby/vendor_ruby/fast_gettext/vendor/string.rb:70:in `%' app/models/block.rb:187:in `content' test/unit/products_block_test.rb:30:in `block in <class:ProductsBlockTest>'
Após corrigir todos os unitários será preciso garantir que os funcionais, integração e cucumber também passam. Em seguida refatorar também os plugins, pois as modificações até o momento foram apenas no core.
-
Corrigi os testes da lista no branch https://gitlab.com/rafamanzo/noosfero/tree/decouple-models-html_part2.
Há outros além deles falhando:
- [*]
test/unit/tags_block_test.rb:31
- [*]
test/unit/tags_block_test.rb:44
- [*]
test/unit/tags_block_test.rb:58
- [*]
test/unit/tags_block_test.rb:62
- [*]
test/unit/tags_block_test.rb:53
- [ ]
test/unit/article_test.rb:792
Bug com docker - [*]
test/unit/cms_helper_test.rb:15
- [*]
test/unit/profile_image_block_test.rb:13
- [*]
test/unit/uploaded_file_test.rb:255
- [*]
test/unit/uploaded_file_test.rb:363
- [*]
test/unit/application_helper_test.rb:1055
Corrigido na master - [*]
test/unit/application_helper_test.rb:1068
Corrigido na master
No sábado vou cuidar deles.
- [*]
-
Depois do rebase da master de hoje, surgiram novas falhas (atualizadas na lista acima):
test/unit/uploaded_file_test.rb:255
test/unit/uploaded_file_test.rb:363
test/unit/application_helper_test.rb:1055
test/unit/application_helper_test.rb:1068
-
Rastreei o erro novo da application_helper para este commit que entrou na master. Durante a semana vou tentar falar com o pessoal que desenvolveu.
De resto os testes para blocos estão todos passando. Vamos torcer para os próximos commits que virem da master não quebrarem mais testes.
-
Pelo bisect, a falha
test/unit/cms_helper_test.rb:15
foi inserido por mim mesmo no commit https://gitlab.com/rafamanzo/noosfero/commit/ff15413b2a8dca45d9f64e57270f294e351a0098?view=inline.Aparentemente o teste deixa algum efeito colateral, pois comentando os testes de view inseridos por esse commit o primeiro volta a passar.
-
Os três testes funcionais falhando no branch de trabalho, tambem falham na master:
- [*] test/functional/profile_controller_test.rb:498
- [*] test/functional/content_viewer_controller_test.rb:669
- [*] test/functional/content_viewer_controller_test.rb:658
-
Todos os testes de integração passam na branch de trabalho.
-
Todos os testes usando cucumber passam na branch de trabalho.
-
MR criado para o trabalho no core: https://gitlab.com/noosfero/noosfero/merge_requests/803
Plugins serão refatorados e terão MRs separados.
-
@manzo, @diguliu deu um feedback no MR, creio que faltou de fato remover o método &content de um bloco:
~/src/noosfero$ ack 'def content' app/models/*_block.rb app/models/profile_list_block.rb 43: def content(args={})
além de que é uma boa fazer logo o mesmo para o método &footer dos blocos. Você pode dar uma olhara nisso?
~/src/noosfero$ ack 'def footer' app/models/*_block.rb app/models/communities_block.rb 30: def footer app/models/enterprises_block.rb 15: def footer app/models/fans_block.rb 15: def footer app/models/favorite_enterprises_block.rb 15: def footer app/models/feed_reader_block.rb 55: def footer app/models/products_block.rb 22: def footer app/models/recent_documents_block.rb 25: def footer app/models/tags_block.rb 31: def footer
-
MR atualizado com as refatorações que faltavam. Os testes continuam passando no ambiente local após essas modificações.
-
Lista de plugins para atualização ordernada do menor para o maior:
- [ ] profile_description_block
- [ ] classify_members
- [N] remote_user
- [N] html5_video
- [ ] variables
- [ ] gallery_block
- [N] template
- [ ] community_block
- [N] pg_search
- [ ] profile_members_headlines
- [N] piwik
- [N] metadata
- [ ] recent_content
- [?] mark_comment_as_read
- [ ] relevant_content
- [?] vote
- [N] volunteers
- [?] lattes_curriculum
- [ ] event
- [N] anti_spam
- [N] google_cse
- [ ] context_content
- [N] analytics
- [N] oauth_provider
- [N] driven_signup
- [ ] container_block
- [N] foo
- [?] ldap
- [?] require_auth_to_comment
- [N] tolerance_time
- [N] delivery
- [?] comment_group
- [N] oauth_client
- [?] work_assignment
- [ ] breadcrumbs
- [?] send_email
- [ ] statistics
- [ ] site_tour
- [ ] newsletter
- [ ] video
- [N] spaminator
- [N] environment_notification
- [ ] people_block
- [?] stoa
- [ ] sub_organizations
- [N] open_graph
- [ ] comment_paragraph
- [ ] organization_ratings
- [?] community_track
- [N] fb_app
- [?] comment_classification
- [N] suppliers
- [N] google_analytics
- [N] orders_cycle
- [N] sniffer
- [N] custom_forms
- [?] social_share_privacy
- [?] pjax
- [?] orders
- [N] responsive
- [ ] display_content
- [N] shopping_cart
- [N] solr
Legenda:
N: não possui HTML acoplado aos models
?: Controverso
R: refatorado
São 63 plugins dos quais 21 precisam de refatoração por HTML acoplado e 14 precisam de mais discussão sobre a necessidade de refatoração.
-
Status changed to closed
-
mentioned in commit dfe77cb838dd678ba590e716f724fe1077415221
-
mentioned in commit 5e0ff19955cb131dee196d756d864ac557877754
-
mentioned in commit 8898935c1b2438a939525942de0c31338f36a13e