From a49d8fe5f9d802bb829e0e63fd8cf18aaeb61bc8 Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Tue, 21 Jul 2015 09:02:14 -0300 Subject: [PATCH] CommunityTrack: load the correct box in functional tests --- plugins/community_track/controllers/myprofile/community_track_plugin_myprofile_controller.rb | 1 - plugins/community_track/controllers/public/community_track_plugin_public_controller.rb | 1 - plugins/community_track/lib/community_track_plugin/track.rb | 3 ++- plugins/community_track/test/functional/community_track_plugin_cms_controller_test.rb | 2 +- plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb | 22 ++++++++-------------- plugins/community_track/test/functional/community_track_plugin_environment_design_controller_test.rb | 2 +- plugins/community_track/test/functional/community_track_plugin_myprofile_controller_test.rb | 8 ++------ plugins/community_track/test/functional/community_track_plugin_public_controller_test.rb | 4 ++-- plugins/community_track/test/test_helper.rb | 2 +- plugins/community_track/test/unit/article_test.rb | 2 +- plugins/community_track/test/unit/community_track_plugin/activation_job_test.rb | 2 +- plugins/community_track/test/unit/community_track_plugin/step_helper_test.rb | 2 +- plugins/community_track/test/unit/community_track_plugin/step_test.rb | 2 +- plugins/community_track/test/unit/community_track_plugin/track_card_list_block_test.rb | 2 +- plugins/community_track/test/unit/community_track_plugin/track_helper_test.rb | 2 +- plugins/community_track/test/unit/community_track_plugin/track_list_block_test.rb | 2 +- plugins/community_track/test/unit/community_track_plugin/track_test.rb | 2 +- plugins/community_track/test/unit/community_track_plugin_test.rb | 2 +- 18 files changed, 26 insertions(+), 37 deletions(-) diff --git a/plugins/community_track/controllers/myprofile/community_track_plugin_myprofile_controller.rb b/plugins/community_track/controllers/myprofile/community_track_plugin_myprofile_controller.rb index 84999f8..e648b55 100644 --- a/plugins/community_track/controllers/myprofile/community_track_plugin_myprofile_controller.rb +++ b/plugins/community_track/controllers/myprofile/community_track_plugin_myprofile_controller.rb @@ -1,5 +1,4 @@ class CommunityTrackPluginMyprofileController < MyProfileController - append_view_path File.join(File.dirname(__FILE__) + '/../../views') before_filter :allow_edit_track, :only => :save_order diff --git a/plugins/community_track/controllers/public/community_track_plugin_public_controller.rb b/plugins/community_track/controllers/public/community_track_plugin_public_controller.rb index ac7a3c1..0808097 100644 --- a/plugins/community_track/controllers/public/community_track_plugin_public_controller.rb +++ b/plugins/community_track/controllers/public/community_track_plugin_public_controller.rb @@ -1,5 +1,4 @@ class CommunityTrackPluginPublicController < PublicController - append_view_path File.join(File.dirname(__FILE__) + '/../../views') no_design_blocks diff --git a/plugins/community_track/lib/community_track_plugin/track.rb b/plugins/community_track/lib/community_track_plugin/track.rb index 7f56570..afd7fed 100644 --- a/plugins/community_track/lib/community_track_plugin/track.rb +++ b/plugins/community_track/lib/community_track_plugin/track.rb @@ -65,7 +65,8 @@ class CommunityTrackPlugin::Track < Folder def category_name category = categories.first - category ? category.top_ancestor.name : '' + category = category.top_ancestor unless category.nil? + category.nil? ? '' : category.name end def to_html(options = {}) diff --git a/plugins/community_track/test/functional/community_track_plugin_cms_controller_test.rb b/plugins/community_track/test/functional/community_track_plugin_cms_controller_test.rb index 1ace0d6..1487afe 100644 --- a/plugins/community_track/test/functional/community_track_plugin_cms_controller_test.rb +++ b/plugins/community_track/test/functional/community_track_plugin_cms_controller_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../test_helper' +require_relative '../test_helper' # Re-raise errors caught by the controller. class CmsController; def rescue_action(e) raise e end; end diff --git a/plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb b/plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb index c254a41..271378f 100644 --- a/plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb +++ b/plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb @@ -1,12 +1,6 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class ContentViewerController - append_view_path File.join(File.dirname(__FILE__) + '/../../views') - def rescue_action(e) - raise e - end -end +require_relative '../test_helper' +class ContentViewerController; def rescue_action(e) raise e end; end class ContentViewerControllerTest < ActionController::TestCase def setup @@ -87,32 +81,32 @@ class ContentViewerControllerTest < ActionController::TestCase end should 'render a div with block id for track list block' do - @block = CommunityTrackPlugin::TrackListBlock.create!(:box => @profile.boxes.last) + @block = CommunityTrackPlugin::TrackListBlock.create!(:box => @profile.boxes.first) get :view_page, @step.url assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" } end should 'render a div with block id for track card list block' do - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last) + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.first) get :view_page, @step.url assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" } end should 'render tracks in track list block' do - @block = CommunityTrackPlugin::TrackListBlock.create!(:box => @profile.boxes.last) + @block = CommunityTrackPlugin::TrackListBlock.create!(:box => @profile.boxes.first) get :view_page, @step.url assert_tag :tag => 'div', :attributes => { :class => "item category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'steps' }, :descendant => { :tag => 'span', :attributes => { :class => "step #{@block.status_class(@step)}" } } } end should 'render tracks in track card list block' do - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last) + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.first) get :view_page, @step.url assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_content' } } assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_stats' } } end should 'render link to display more tracks in track list block' do - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last) + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.first) (@block.limit+1).times { |i| create_track("track#{i}", @profile) } get :view_page, @step.url @@ -120,7 +114,7 @@ class ContentViewerControllerTest < ActionController::TestCase end should 'render link to show all tracks in track list block' do - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last) + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.first) @block.more_another_page = true @block.save! diff --git a/plugins/community_track/test/functional/community_track_plugin_environment_design_controller_test.rb b/plugins/community_track/test/functional/community_track_plugin_environment_design_controller_test.rb index fe69082..e09d1ef 100644 --- a/plugins/community_track/test/functional/community_track_plugin_environment_design_controller_test.rb +++ b/plugins/community_track/test/functional/community_track_plugin_environment_design_controller_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../test_helper' +require_relative '../test_helper' # Re-raise errors caught by the controller. class EnvironmentDesignController; def rescue_action(e) raise e end; end diff --git a/plugins/community_track/test/functional/community_track_plugin_myprofile_controller_test.rb b/plugins/community_track/test/functional/community_track_plugin_myprofile_controller_test.rb index faa5cde..276d9f3 100644 --- a/plugins/community_track/test/functional/community_track_plugin_myprofile_controller_test.rb +++ b/plugins/community_track/test/functional/community_track_plugin_myprofile_controller_test.rb @@ -1,5 +1,5 @@ -require File.dirname(__FILE__) + '/../test_helper' -require File.dirname(__FILE__) + '/../../controllers/myprofile/community_track_plugin_myprofile_controller' +require_relative '../test_helper' +require_relative '../../controllers/myprofile/community_track_plugin_myprofile_controller' # Re-raise errors caught by the controller. class CommunityTrackPluginMyprofileController; def rescue_action(e) raise e end; end @@ -7,10 +7,6 @@ class CommunityTrackPluginMyprofileController; def rescue_action(e) raise e end; class CommunityTrackPluginMyprofileControllerTest < ActionController::TestCase def setup - @controller = CommunityTrackPluginMyprofileController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @profile = fast_create(Community) @track = create_track('track', @profile) diff --git a/plugins/community_track/test/functional/community_track_plugin_public_controller_test.rb b/plugins/community_track/test/functional/community_track_plugin_public_controller_test.rb index 40f19ea..a6ad411 100644 --- a/plugins/community_track/test/functional/community_track_plugin_public_controller_test.rb +++ b/plugins/community_track/test/functional/community_track_plugin_public_controller_test.rb @@ -1,5 +1,5 @@ -require File.dirname(__FILE__) + '/../test_helper' -require File.dirname(__FILE__) + '/../../controllers/public/community_track_plugin_public_controller' +require_relative '../test_helper' +require_relative '../../controllers/public/community_track_plugin_public_controller' # Re-raise errors caught by the controller. class CommunityTrackPluginPublicController; def rescue_action(e) raise e end; end diff --git a/plugins/community_track/test/test_helper.rb b/plugins/community_track/test/test_helper.rb index 8e64f83..774ad8f 100644 --- a/plugins/community_track/test/test_helper.rb +++ b/plugins/community_track/test/test_helper.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../test/test_helper' +require_relative '../../../test/test_helper' def create_track(name, profile) track = CommunityTrackPlugin::Track.new(:abstract => 'abstract', :body => 'body', :name => name, :profile => profile) diff --git a/plugins/community_track/test/unit/article_test.rb b/plugins/community_track/test/unit/article_test.rb index 6e47b30..443e24e 100644 --- a/plugins/community_track/test/unit/article_test.rb +++ b/plugins/community_track/test/unit/article_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../test_helper' +require_relative '../test_helper' class ArticleTest < ActiveSupport::TestCase diff --git a/plugins/community_track/test/unit/community_track_plugin/activation_job_test.rb b/plugins/community_track/test/unit/community_track_plugin/activation_job_test.rb index 049096a..8d14fec 100644 --- a/plugins/community_track/test/unit/community_track_plugin/activation_job_test.rb +++ b/plugins/community_track/test/unit/community_track_plugin/activation_job_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../test_helper' +require_relative '../../test_helper' class ActivationJobTest < ActiveSupport::TestCase diff --git a/plugins/community_track/test/unit/community_track_plugin/step_helper_test.rb b/plugins/community_track/test/unit/community_track_plugin/step_helper_test.rb index cfec65e..a7ed3cc 100644 --- a/plugins/community_track/test/unit/community_track_plugin/step_helper_test.rb +++ b/plugins/community_track/test/unit/community_track_plugin/step_helper_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../test_helper' +require_relative '../../test_helper' class StepHelperTest < ActiveSupport::TestCase diff --git a/plugins/community_track/test/unit/community_track_plugin/step_test.rb b/plugins/community_track/test/unit/community_track_plugin/step_test.rb index 00f298b..3414ab4 100644 --- a/plugins/community_track/test/unit/community_track_plugin/step_test.rb +++ b/plugins/community_track/test/unit/community_track_plugin/step_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../test_helper' +require_relative '../../test_helper' class StepTest < ActiveSupport::TestCase diff --git a/plugins/community_track/test/unit/community_track_plugin/track_card_list_block_test.rb b/plugins/community_track/test/unit/community_track_plugin/track_card_list_block_test.rb index c8fc228..cf1d55e 100644 --- a/plugins/community_track/test/unit/community_track_plugin/track_card_list_block_test.rb +++ b/plugins/community_track/test/unit/community_track_plugin/track_card_list_block_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../test_helper' +require_relative '../../test_helper' class TrackCardListBlockTest < ActiveSupport::TestCase diff --git a/plugins/community_track/test/unit/community_track_plugin/track_helper_test.rb b/plugins/community_track/test/unit/community_track_plugin/track_helper_test.rb index 69caa99..9751291 100644 --- a/plugins/community_track/test/unit/community_track_plugin/track_helper_test.rb +++ b/plugins/community_track/test/unit/community_track_plugin/track_helper_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../test_helper' +require_relative '../../test_helper' class TrackHelperTest < ActiveSupport::TestCase diff --git a/plugins/community_track/test/unit/community_track_plugin/track_list_block_test.rb b/plugins/community_track/test/unit/community_track_plugin/track_list_block_test.rb index 864dd2d..498dd71 100644 --- a/plugins/community_track/test/unit/community_track_plugin/track_list_block_test.rb +++ b/plugins/community_track/test/unit/community_track_plugin/track_list_block_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../test_helper' +require_relative '../../test_helper' class TrackListBlockTest < ActiveSupport::TestCase diff --git a/plugins/community_track/test/unit/community_track_plugin/track_test.rb b/plugins/community_track/test/unit/community_track_plugin/track_test.rb index ce4602d..58d9841 100644 --- a/plugins/community_track/test/unit/community_track_plugin/track_test.rb +++ b/plugins/community_track/test/unit/community_track_plugin/track_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../test_helper' +require_relative '../../test_helper' class TrackTest < ActiveSupport::TestCase diff --git a/plugins/community_track/test/unit/community_track_plugin_test.rb b/plugins/community_track/test/unit/community_track_plugin_test.rb index 634ea5f..d0c0beb 100644 --- a/plugins/community_track/test/unit/community_track_plugin_test.rb +++ b/plugins/community_track/test/unit/community_track_plugin_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../test_helper' +require_relative '../test_helper' class CommunityTrackPluginTest < ActiveSupport::TestCase -- libgit2 0.21.2