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,14 +38,14 @@ class CommunityHubPluginPublicControllerTest < ActionController::TestCase | ||
| 38 | 38 | ||
| 39 | attr_reader :user, :environment, :community, :hub | 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 | message = create_message( hub, user ) | 42 | message = create_message( hub, user ) |
| 43 | login_as(user.user.login) | 43 | login_as(user.user.login) |
| 44 | xhr :get, :newer_comments, { :latest_post => 0, :hub => hub.id } | 44 | xhr :get, :newer_comments, { :latest_post => 0, :hub => hub.id } |
| 45 | assert_tag :tag => 'li', :attributes => { :class => 'pin' } | 45 | assert_tag :tag => 'li', :attributes => { :class => 'pin' } |
| 46 | end | 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 | message = create_message( hub, user ) | 49 | message = create_message( hub, user ) |
| 50 | visitor = create_user('visitor') | 50 | visitor = create_user('visitor') |
| 51 | login_as(visitor.login) | 51 | login_as(visitor.login) |
| @@ -75,14 +75,14 @@ class CommunityHubPluginPublicControllerTest < ActionController::TestCase | @@ -75,14 +75,14 @@ class CommunityHubPluginPublicControllerTest < ActionController::TestCase | ||
| 75 | } | 75 | } |
| 76 | end | 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 | mediation = create_mediation(hub, user, community) | 79 | mediation = create_mediation(hub, user, community) |
| 80 | login_as(user.user.login) | 80 | login_as(user.user.login) |
| 81 | xhr :get, :newer_articles, { :latest_post => 0, :hub => hub.id } | 81 | xhr :get, :newer_articles, { :latest_post => 0, :hub => hub.id } |
| 82 | assert_tag :tag => 'li', :attributes => { :class => 'promote' } | 82 | assert_tag :tag => 'li', :attributes => { :class => 'promote' } |
| 83 | end | 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 | mediation = create_mediation(hub, user, community) | 86 | mediation = create_mediation(hub, user, community) |
| 87 | visitor = create_user('visitor') | 87 | visitor = create_user('visitor') |
| 88 | login_as(visitor.login) | 88 | login_as(visitor.login) |
| @@ -120,5 +120,67 @@ class CommunityHubPluginPublicControllerTest < ActionController::TestCase | @@ -120,5 +120,67 @@ class CommunityHubPluginPublicControllerTest < ActionController::TestCase | ||
| 120 | } | 120 | } |
| 121 | end | 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 | end | 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 +7,7 @@ class MediationTest < ActiveSupport::TestCase | ||
| 7 | @user = create_user('testuser', :environment => @env).person | 7 | @user = create_user('testuser', :environment => @env).person |
| 8 | @comm = fast_create(Community, :environment_id => @env.id) | 8 | @comm = fast_create(Community, :environment_id => @env.id) |
| 9 | @hub = create_hub('hub', @comm, @user) | 9 | @hub = create_hub('hub', @comm, @user) |
| 10 | - @mediation = create_mediation(@hub, @comm) | 10 | + @mediation = create_mediation(@hub, @user, @comm) |
| 11 | end | 11 | end |
| 12 | 12 | ||
| 13 | should 'has setting profile_picture' do | 13 | should 'has setting profile_picture' do |