Commit a49d8fe5f9d802bb829e0e63fd8cf18aaeb61bc8
1 parent
e833fc77
Exists in
master
and in
22 other branches
CommunityTrack: load the correct box in functional tests
Showing
18 changed files
with
26 additions
and
37 deletions
Show diff stats
plugins/community_track/controllers/myprofile/community_track_plugin_myprofile_controller.rb
| 1 | class CommunityTrackPluginMyprofileController < MyProfileController | 1 | class CommunityTrackPluginMyprofileController < MyProfileController |
| 2 | - append_view_path File.join(File.dirname(__FILE__) + '/../../views') | ||
| 3 | 2 | ||
| 4 | before_filter :allow_edit_track, :only => :save_order | 3 | before_filter :allow_edit_track, :only => :save_order |
| 5 | 4 |
plugins/community_track/controllers/public/community_track_plugin_public_controller.rb
plugins/community_track/lib/community_track_plugin/track.rb
| @@ -65,7 +65,8 @@ class CommunityTrackPlugin::Track < Folder | @@ -65,7 +65,8 @@ class CommunityTrackPlugin::Track < Folder | ||
| 65 | 65 | ||
| 66 | def category_name | 66 | def category_name |
| 67 | category = categories.first | 67 | category = categories.first |
| 68 | - category ? category.top_ancestor.name : '' | 68 | + category = category.top_ancestor unless category.nil? |
| 69 | + category.nil? ? '' : category.name | ||
| 69 | end | 70 | end |
| 70 | 71 | ||
| 71 | def to_html(options = {}) | 72 | def to_html(options = {}) |
plugins/community_track/test/functional/community_track_plugin_cms_controller_test.rb
| 1 | -require File.dirname(__FILE__) + '/../test_helper' | 1 | +require_relative '../test_helper' |
| 2 | 2 | ||
| 3 | # Re-raise errors caught by the controller. | 3 | # Re-raise errors caught by the controller. |
| 4 | class CmsController; def rescue_action(e) raise e end; end | 4 | class CmsController; def rescue_action(e) raise e end; end |
plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb
| 1 | -require File.dirname(__FILE__) + '/../test_helper' | ||
| 2 | - | ||
| 3 | -class ContentViewerController | ||
| 4 | - append_view_path File.join(File.dirname(__FILE__) + '/../../views') | ||
| 5 | - def rescue_action(e) | ||
| 6 | - raise e | ||
| 7 | - end | ||
| 8 | -end | 1 | +require_relative '../test_helper' |
| 9 | 2 | ||
| 3 | +class ContentViewerController; def rescue_action(e) raise e end; end | ||
| 10 | class ContentViewerControllerTest < ActionController::TestCase | 4 | class ContentViewerControllerTest < ActionController::TestCase |
| 11 | 5 | ||
| 12 | def setup | 6 | def setup |
| @@ -87,32 +81,32 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -87,32 +81,32 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
| 87 | end | 81 | end |
| 88 | 82 | ||
| 89 | should 'render a div with block id for track list block' do | 83 | should 'render a div with block id for track list block' do |
| 90 | - @block = CommunityTrackPlugin::TrackListBlock.create!(:box => @profile.boxes.last) | 84 | + @block = CommunityTrackPlugin::TrackListBlock.create!(:box => @profile.boxes.first) |
| 91 | get :view_page, @step.url | 85 | get :view_page, @step.url |
| 92 | assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" } | 86 | assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" } |
| 93 | end | 87 | end |
| 94 | 88 | ||
| 95 | should 'render a div with block id for track card list block' do | 89 | should 'render a div with block id for track card list block' do |
| 96 | - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last) | 90 | + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.first) |
| 97 | get :view_page, @step.url | 91 | get :view_page, @step.url |
| 98 | assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" } | 92 | assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" } |
| 99 | end | 93 | end |
| 100 | 94 | ||
| 101 | should 'render tracks in track list block' do | 95 | should 'render tracks in track list block' do |
| 102 | - @block = CommunityTrackPlugin::TrackListBlock.create!(:box => @profile.boxes.last) | 96 | + @block = CommunityTrackPlugin::TrackListBlock.create!(:box => @profile.boxes.first) |
| 103 | get :view_page, @step.url | 97 | get :view_page, @step.url |
| 104 | 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)}" } } } | 98 | 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)}" } } } |
| 105 | end | 99 | end |
| 106 | 100 | ||
| 107 | should 'render tracks in track card list block' do | 101 | should 'render tracks in track card list block' do |
| 108 | - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last) | 102 | + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.first) |
| 109 | get :view_page, @step.url | 103 | get :view_page, @step.url |
| 110 | assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_content' } } | 104 | assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_content' } } |
| 111 | assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_stats' } } | 105 | assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_stats' } } |
| 112 | end | 106 | end |
| 113 | 107 | ||
| 114 | should 'render link to display more tracks in track list block' do | 108 | should 'render link to display more tracks in track list block' do |
| 115 | - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last) | 109 | + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.first) |
| 116 | (@block.limit+1).times { |i| create_track("track#{i}", @profile) } | 110 | (@block.limit+1).times { |i| create_track("track#{i}", @profile) } |
| 117 | 111 | ||
| 118 | get :view_page, @step.url | 112 | get :view_page, @step.url |
| @@ -120,7 +114,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -120,7 +114,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
| 120 | end | 114 | end |
| 121 | 115 | ||
| 122 | should 'render link to show all tracks in track list block' do | 116 | should 'render link to show all tracks in track list block' do |
| 123 | - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last) | 117 | + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.first) |
| 124 | @block.more_another_page = true | 118 | @block.more_another_page = true |
| 125 | @block.save! | 119 | @block.save! |
| 126 | 120 |
plugins/community_track/test/functional/community_track_plugin_environment_design_controller_test.rb
| 1 | -require File.dirname(__FILE__) + '/../test_helper' | 1 | +require_relative '../test_helper' |
| 2 | 2 | ||
| 3 | # Re-raise errors caught by the controller. | 3 | # Re-raise errors caught by the controller. |
| 4 | class EnvironmentDesignController; def rescue_action(e) raise e end; end | 4 | class EnvironmentDesignController; def rescue_action(e) raise e end; end |
plugins/community_track/test/functional/community_track_plugin_myprofile_controller_test.rb
| 1 | -require File.dirname(__FILE__) + '/../test_helper' | ||
| 2 | -require File.dirname(__FILE__) + '/../../controllers/myprofile/community_track_plugin_myprofile_controller' | 1 | +require_relative '../test_helper' |
| 2 | +require_relative '../../controllers/myprofile/community_track_plugin_myprofile_controller' | ||
| 3 | 3 | ||
| 4 | # Re-raise errors caught by the controller. | 4 | # Re-raise errors caught by the controller. |
| 5 | class CommunityTrackPluginMyprofileController; def rescue_action(e) raise e end; end | 5 | class CommunityTrackPluginMyprofileController; def rescue_action(e) raise e end; end |
| @@ -7,10 +7,6 @@ class CommunityTrackPluginMyprofileController; def rescue_action(e) raise e end; | @@ -7,10 +7,6 @@ class CommunityTrackPluginMyprofileController; def rescue_action(e) raise e end; | ||
| 7 | class CommunityTrackPluginMyprofileControllerTest < ActionController::TestCase | 7 | class CommunityTrackPluginMyprofileControllerTest < ActionController::TestCase |
| 8 | 8 | ||
| 9 | def setup | 9 | def setup |
| 10 | - @controller = CommunityTrackPluginMyprofileController.new | ||
| 11 | - @request = ActionController::TestRequest.new | ||
| 12 | - @response = ActionController::TestResponse.new | ||
| 13 | - | ||
| 14 | @profile = fast_create(Community) | 10 | @profile = fast_create(Community) |
| 15 | @track = create_track('track', @profile) | 11 | @track = create_track('track', @profile) |
| 16 | 12 |
plugins/community_track/test/functional/community_track_plugin_public_controller_test.rb
| 1 | -require File.dirname(__FILE__) + '/../test_helper' | ||
| 2 | -require File.dirname(__FILE__) + '/../../controllers/public/community_track_plugin_public_controller' | 1 | +require_relative '../test_helper' |
| 2 | +require_relative '../../controllers/public/community_track_plugin_public_controller' | ||
| 3 | 3 | ||
| 4 | # Re-raise errors caught by the controller. | 4 | # Re-raise errors caught by the controller. |
| 5 | class CommunityTrackPluginPublicController; def rescue_action(e) raise e end; end | 5 | class CommunityTrackPluginPublicController; def rescue_action(e) raise e end; end |
plugins/community_track/test/test_helper.rb
| 1 | -require File.dirname(__FILE__) + '/../../../test/test_helper' | 1 | +require_relative '../../../test/test_helper' |
| 2 | 2 | ||
| 3 | def create_track(name, profile) | 3 | def create_track(name, profile) |
| 4 | track = CommunityTrackPlugin::Track.new(:abstract => 'abstract', :body => 'body', :name => name, :profile => profile) | 4 | track = CommunityTrackPlugin::Track.new(:abstract => 'abstract', :body => 'body', :name => name, :profile => profile) |
plugins/community_track/test/unit/article_test.rb
plugins/community_track/test/unit/community_track_plugin/activation_job_test.rb
plugins/community_track/test/unit/community_track_plugin/step_helper_test.rb
plugins/community_track/test/unit/community_track_plugin/step_test.rb
plugins/community_track/test/unit/community_track_plugin/track_card_list_block_test.rb
plugins/community_track/test/unit/community_track_plugin/track_helper_test.rb
plugins/community_track/test/unit/community_track_plugin/track_list_block_test.rb
plugins/community_track/test/unit/community_track_plugin/track_test.rb
plugins/community_track/test/unit/community_track_plugin_test.rb