Commit e137c34df22d1463574a2af3f197c81fd5181a6f

Authored by Rodrigo Souto
1 parent aae9aa42

community-track-plugin: fix tests by creating a profile with default boxes

plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb
... ... @@ -10,7 +10,7 @@ end
10 10 class ContentViewerControllerTest < ActionController::TestCase
11 11  
12 12 def setup
13   - @profile = fast_create(Community)
  13 + @profile = Community.create!(:name => 'Sample community', :identifier => 'sample-community')
14 14 @track = create_track('track', @profile)
15 15 @step = CommunityTrackPlugin::Step.create!(:name => 'step1', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => Date.today, :start_date => Date.today, :tool_type => TinyMceArticle.name)
16 16  
... ... @@ -87,43 +87,35 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
87 87 end
88 88  
89 89 should 'render a div with block id for track list block' do
90   - box = fast_create(Box, :owner_id => @profile.id, :owner_type => @profile.class.name)
91   - @block = CommunityTrackPlugin::TrackListBlock.create!(:box => box)
92   - @profile.boxes << box
  90 + @block = CommunityTrackPlugin::TrackListBlock.create!(:box => @profile.boxes.last)
93 91 get :view_page, @step.url
94 92 assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" }
95 93 end
96 94  
97 95 should 'render a div with block id for track card list block' do
98   - box = fast_create(Box, :owner_id => @profile.id, :owner_type => @profile.class.name)
99   - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => box)
100   - @profile.boxes << box
  96 + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last)
101 97 get :view_page, @step.url
102 98 assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" }
103 99 end
104 100  
105 101 should 'render tracks in track list block' do
106   - box = fast_create(Box, :owner_id => @profile.id, :owner_type => @profile.class.name)
107   - @block = CommunityTrackPlugin::TrackListBlock.create!(:box => box)
108   - @profile.boxes << box
  102 + @block = CommunityTrackPlugin::TrackListBlock.create!(:box => @profile.boxes.last)
109 103 get :view_page, @step.url
  104 + file = File.open('result.html', 'w+')
  105 + file.write(@response.body)
  106 + file.close
110 107 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)}" } } }
111 108 end
112 109  
113 110 should 'render tracks in track card list block' do
114   - box = fast_create(Box, :owner_id => @profile.id, :owner_type => @profile.class.name)
115   - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => box)
116   - @profile.boxes << box
  111 + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last)
117 112 get :view_page, @step.url
118 113 assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_content' } }
119 114 assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_stats' } }
120 115 end
121 116  
122 117 should 'render link to display more tracks in track list block' do
123   - box = fast_create(Box, :owner_id => @profile.id, :owner_type => @profile.class.name)
124   - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => box)
125   - @profile.boxes << box
126   -
  118 + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last)
127 119 (@block.limit+1).times { |i| create_track("track#{i}", @profile) }
128 120  
129 121 get :view_page, @step.url
... ... @@ -131,9 +123,7 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
131 123 end
132 124  
133 125 should 'render link to show all tracks in track list block' do
134   - box = fast_create(Box, :owner_id => @profile.id, :owner_type => @profile.class.name)
135   - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => box)
136   - @profile.boxes << box
  126 + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last)
137 127 @block.more_another_page = true
138 128 @block.save!
139 129  
... ...