Commit 9b6bcaf76dccaa72ed59be8fb465a575a5a9bc27
1 parent
9e8fd78e
Exists in
master
and in
29 other branches
community_track: fix tests
Showing
1 changed file
with
16 additions
and
13 deletions
Show diff stats
plugins/community_track/test/unit/community_track_plugin_test.rb
... | ... | @@ -6,10 +6,13 @@ class CommunityTrackPluginTest < ActiveSupport::TestCase |
6 | 6 | @plugin = CommunityTrackPlugin.new |
7 | 7 | @profile = fast_create(Community) |
8 | 8 | @params = {} |
9 | - @plugin.stubs(:context).returns(self) | |
9 | + @context = mock | |
10 | + @context.stubs(:profile).returns(@profile) | |
11 | + @context.stubs(:params).returns(@params) | |
12 | + @plugin.stubs(:context).returns(@context) | |
10 | 13 | end |
11 | 14 | |
12 | - attr_reader :profile, :params | |
15 | + attr_reader :profile, :params, :context | |
13 | 16 | |
14 | 17 | should 'has name' do |
15 | 18 | assert CommunityTrackPlugin.plugin_name |
... | ... | @@ -28,37 +31,37 @@ class CommunityTrackPluginTest < ActiveSupport::TestCase |
28 | 31 | end |
29 | 32 | |
30 | 33 | should 'do not return Track as a content type if profile is not a community' do |
31 | - @profile = Organization.new | |
34 | + context.stubs(:profile).returns(Organization.new) | |
32 | 35 | assert_not_includes @plugin.content_types, CommunityTrackPlugin::Track |
33 | 36 | end |
34 | 37 | |
35 | 38 | should 'do not return Track as a content type if there is a parent' do |
36 | - parent = fast_create(Blog, :profile_id => @profile.id) | |
37 | - @params[:parent_id] = parent.id | |
39 | + parent = fast_create(Blog, :profile_id => profile.id) | |
40 | + params[:parent_id] = parent.id | |
38 | 41 | assert_not_includes @plugin.content_types, CommunityTrackPlugin::Track |
39 | 42 | end |
40 | 43 | |
41 | 44 | should 'return Step as a content type if parent is a Track' do |
42 | - parent = fast_create(CommunityTrackPlugin::Track, :profile_id => @profile.id) | |
43 | - @params[:parent_id] = parent.id | |
45 | + parent = fast_create(CommunityTrackPlugin::Track, :profile_id => profile.id) | |
46 | + params[:parent_id] = parent.id | |
44 | 47 | assert_includes @plugin.content_types, CommunityTrackPlugin::Step |
45 | 48 | end |
46 | 49 | |
47 | 50 | should 'do not return Step as a content type if parent is not a Track' do |
48 | - parent = fast_create(Blog, :profile_id => @profile.id) | |
49 | - @params[:parent_id] = parent.id | |
51 | + parent = fast_create(Blog, :profile_id => profile.id) | |
52 | + params[:parent_id] = parent.id | |
50 | 53 | assert_not_includes @plugin.content_types, CommunityTrackPlugin::Step |
51 | 54 | end |
52 | 55 | |
53 | 56 | should 'return Track and Step as a content type if context has no params' do |
54 | - parent = fast_create(Blog, :profile_id => @profile.id) | |
55 | - expects(:respond_to?).with(:params).returns(false) | |
57 | + parent = fast_create(Blog, :profile_id => profile.id) | |
58 | + context.expects(:respond_to?).with(:params).returns(false) | |
56 | 59 | assert_equivalent [CommunityTrackPlugin::Step, CommunityTrackPlugin::Track], @plugin.content_types |
57 | 60 | end |
58 | 61 | |
59 | 62 | should 'return Track and Step as a content type if params is nil' do |
60 | - parent = fast_create(Blog, :profile_id => @profile.id) | |
61 | - @params = nil | |
63 | + parent = fast_create(Blog, :profile_id => profile.id) | |
64 | + context.stubs(:params).returns(nil) | |
62 | 65 | assert_equivalent [CommunityTrackPlugin::Step, CommunityTrackPlugin::Track], @plugin.content_types |
63 | 66 | end |
64 | 67 | ... | ... |