Commit f0f70e285cd39d19a5226af9847e29fc06315b96
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'rails3_community_dashboard' into rails3_stable
Showing
2 changed files
with
67 additions
and
5 deletions
Show diff stats
plugins/community_hub/test/functional/community_hub_plugin_public_controller_test.rb
| ... | ... | @@ -38,14 +38,14 @@ class CommunityHubPluginPublicControllerTest < ActionController::TestCase |
| 38 | 38 | |
| 39 | 39 | attr_reader :user, :environment, :community, :hub |
| 40 | 40 | |
| 41 | - should 'display pin message flag if user is logged and hub\'s mediator' do | |
| 41 | + should 'display pin message flag if user is logged and mediator' do | |
| 42 | 42 | message = create_message( hub, user ) |
| 43 | 43 | login_as(user.user.login) |
| 44 | 44 | xhr :get, :newer_comments, { :latest_post => 0, :hub => hub.id } |
| 45 | 45 | assert_tag :tag => 'li', :attributes => { :class => 'pin' } |
| 46 | 46 | end |
| 47 | 47 | |
| 48 | - should 'not display pin message flag if user is not hub'' mediator' do | |
| 48 | + should 'not display pin message flag if user is not mediator' do | |
| 49 | 49 | message = create_message( hub, user ) |
| 50 | 50 | visitor = create_user('visitor') |
| 51 | 51 | login_as(visitor.login) |
| ... | ... | @@ -75,14 +75,14 @@ class CommunityHubPluginPublicControllerTest < ActionController::TestCase |
| 75 | 75 | } |
| 76 | 76 | end |
| 77 | 77 | |
| 78 | - should 'display promote user flag if user is logged and hub\s mediator' do | |
| 78 | + should 'display promote user flag if user is logged and mediator' do | |
| 79 | 79 | mediation = create_mediation(hub, user, community) |
| 80 | 80 | login_as(user.user.login) |
| 81 | 81 | xhr :get, :newer_articles, { :latest_post => 0, :hub => hub.id } |
| 82 | 82 | assert_tag :tag => 'li', :attributes => { :class => 'promote' } |
| 83 | 83 | end |
| 84 | 84 | |
| 85 | - should 'not display promote user flag if user is not hub''s mediator' do | |
| 85 | + should 'not display promote user flag if user is not mediator' do | |
| 86 | 86 | mediation = create_mediation(hub, user, community) |
| 87 | 87 | visitor = create_user('visitor') |
| 88 | 88 | login_as(visitor.login) |
| ... | ... | @@ -120,5 +120,67 @@ class CommunityHubPluginPublicControllerTest < ActionController::TestCase |
| 120 | 120 | } |
| 121 | 121 | end |
| 122 | 122 | |
| 123 | + should 'should create new message' do | |
| 124 | + login_as(user.user.login) | |
| 125 | + xhr :post, :new_message, { :article_id => hub.id, :message => {"body"=>"testmessage"} } | |
| 126 | + response = JSON.parse(@response.body) | |
| 127 | + assert_equal true, response['ok'] | |
| 128 | + end | |
| 129 | + | |
| 130 | + should 'should create new mediation' do | |
| 131 | + login_as(user.user.login) | |
| 132 | + xhr :post, :new_mediation, { :profile_id => community.id, :article => { "parent_id" => hub.id , "body" => "<p>testmediation</p>" } } | |
| 133 | + response = JSON.parse(@response.body) | |
| 134 | + assert_equal true, response['ok'] | |
| 135 | + end | |
| 136 | + | |
| 137 | + should 'should create new mediation comment' do | |
| 138 | + login_as(user.user.login) | |
| 139 | + mediation = create_mediation(hub, user, community) | |
| 140 | + xhr :post, :new_message, { "article_id" => mediation.id, "message" => {"body"=>"testmediationcomment"} } | |
| 141 | + response = JSON.parse(@response.body) | |
| 142 | + assert_equal true, response['ok'] | |
| 143 | + end | |
| 144 | + | |
| 145 | + should 'should get newer messages' do | |
| 146 | + message1 = create_message( hub, user ) | |
| 147 | + message2 = create_message( hub, user ) | |
| 148 | + message3 = create_message( hub, user ) | |
| 149 | + xhr :get, :newer_comments, { :latest_post => message2.id, :hub => hub.id } | |
| 150 | + assert_tag :tag => 'li', :attributes => { :id => message3.id } | |
| 151 | + end | |
| 152 | + | |
| 153 | + should 'should get oldest messages' do | |
| 154 | + message1 = create_message( hub, user ) | |
| 155 | + message2 = create_message( hub, user ) | |
| 156 | + message3 = create_message( hub, user ) | |
| 157 | + xhr :get, :older_comments, { :oldest_id => message2.id, :hub => hub.id } | |
| 158 | + assert_tag :tag => 'li', :attributes => { :id => message1.id } | |
| 159 | + end | |
| 160 | + | |
| 161 | + should 'should get newer mediations' do | |
| 162 | + mediation1 = create_mediation(hub, user, community) | |
| 163 | + mediation2 = create_mediation(hub, user, community) | |
| 164 | + mediation3 = create_mediation(hub, user, community) | |
| 165 | + xhr :get, :newer_articles, { :latest_post => mediation2.id, :hub => hub.id } | |
| 166 | + assert_tag :tag => 'li', :attributes => { :id => mediation3.id } | |
| 167 | + end | |
| 168 | + | |
| 169 | + should 'should promote user' do | |
| 170 | + login_as(user.user.login) | |
| 171 | + visitor = create_user('visitor').person | |
| 172 | + xhr :post, :promote_user, { :hub => hub.id, :user => visitor.id } | |
| 173 | + response = JSON.parse(@response.body) | |
| 174 | + assert_equal true, response['ok'] | |
| 175 | + end | |
| 176 | + | |
| 177 | + should 'should pin message' do | |
| 178 | + login_as(user.user.login) | |
| 179 | + message = create_message( hub, user ) | |
| 180 | + xhr :post, :pin_message, { :hub => hub.id, :message => message.id } | |
| 181 | + response = JSON.parse(@response.body) | |
| 182 | + assert_equal true, response['ok'] | |
| 183 | + end | |
| 184 | + | |
| 123 | 185 | end |
| 124 | 186 | ... | ... |
plugins/community_hub/test/unit/community_hub_plugin/mediation_test.rb
| ... | ... | @@ -7,7 +7,7 @@ class MediationTest < ActiveSupport::TestCase |
| 7 | 7 | @user = create_user('testuser', :environment => @env).person |
| 8 | 8 | @comm = fast_create(Community, :environment_id => @env.id) |
| 9 | 9 | @hub = create_hub('hub', @comm, @user) |
| 10 | - @mediation = create_mediation(@hub, @comm) | |
| 10 | + @mediation = create_mediation(@hub, @user, @comm) | |
| 11 | 11 | end |
| 12 | 12 | |
| 13 | 13 | should 'has setting profile_picture' do | ... | ... |