diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d193b73..160da6d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1250,11 +1250,19 @@ module ApplicationHelper already_reported_message = _('You already reported this profile.') report_profile_message = _('Report this profile for abusive behaviour') - if type == :button + if type == :button || type == :button_without_text if user.already_reported?(profile) - button(:alert, text, url, :class => klass+' disabled', :disabled => true, :title => already_reported_message) + if type == :button + button(:alert, text, url, :class => klass+' disabled', :disabled => true, :title => already_reported_message) + elsif type == :button_without_text + button_without_text(:alert, text, url, :class => klass+' disabled', :disabled => true, :title => already_reported_message) + end else - button(:alert, text, url, :class => klass, :title => report_profile_message) + if type == :button + button(:alert, text, url, :class => klass, :title => report_profile_message) + elsif type == :button_without_text + button_without_text(:alert, text, url, :class => klass, :title => report_profile_message) + end end elsif type == :link if user.already_reported?(profile) diff --git a/plugins/community_block/public/style.css b/plugins/community_block/public/style.css index 9da2b23..60df06f 100644 --- a/plugins/community_block/public/style.css +++ b/plugins/community_block/public/style.css @@ -38,6 +38,8 @@ #content .box-1 .community-block .community-block-buttons { //border: 1px solid #F00; - text-align: right; + text-align: left; + margin-top: 3px; + margin-left: 22px; } diff --git a/plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb b/plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb index 7f7794b..8ecb1e5 100644 --- a/plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb +++ b/plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb @@ -15,10 +15,12 @@ class ProfileControllerTest < ActionController::TestCase @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - #user = create_user('testinguser') - #login_as(user.login) + @user = create_user('testinguser').person + login_as(@user.identifier) @community = fast_create(Community, :environment_id => Environment.default) + @community.add_member @user + @community.add_admin @user @environment = @community.environment @environment.enabled_plugins = ['CommunityBlock'] @@ -36,31 +38,81 @@ class ProfileControllerTest < ActionController::TestCase @community.save! end - attr_accessor :profile, :block, :community - - should 'display community-block-logo class in community block' do - get :index, :profile => community.identifier + should 'display community-block' do + get :index, :profile => @community.identifier assert_tag :div, :attributes => {:class => 'community-block-logo'} + assert_tag :div, :attributes => {:class => 'community-block-info'} + assert_tag :h1, :attributes => {:class => 'community-block-title'} + assert_tag :div, :attributes => {:class => 'community-block-description'} + assert_tag :div, :attributes => {:class => 'community-block-buttons'} end - should 'display community-block-info class in community block' do - get :index, :profile => community.identifier - assert_tag :div, :attributes => {:class => 'community-block-info'} + + # USER LOGGED IN AND COMMUNITY MEMBER # + + should 'display *leave* button when the user is logged in and is a member of the community' do + get :index, :profile => @community.identifier + assert_tag :a, :attributes => {:class => 'button icon-remove'} end - should 'display community-block-title class in community block' do - get :index, :profile => community.identifier - assert_tag :h1, :attributes => {:class => 'community-block-title'} + should 'display *send email to administrators* button when the user is logged in and is a member of the community' do + get :index, :profile => @community.identifier + assert_tag :a, :attributes => {:class => 'button icon-menu-mail'} end - should 'display community-block-description class in community block' do - get :index, :profile => community.identifier - assert_tag :div, :attributes => {:class => 'community-block-description'} + should 'display *report* button when the user is logged in and is a member of the community' do + get :index, :profile => @community.identifier + assert_tag :a, :attributes => {:class => 'button icon-alert report-abuse-action'} end - should 'display community-block-buttons class in community block' do - get :index, :profile => community.identifier - assert_tag :div, :attributes => {:class => 'community-block-buttons'} + + # USER LOGGED IN AND NOT MEMBER OF THE COMMUNITY + + should 'display *join* button when the user is logged in and is not a member of the community' do + @community.remove_member @user + get :index, :profile => @community.identifier + assert_tag :a, :attributes => {:class => 'button icon-add'} + end + + should 'display *send email to administrators* button when the user is logged in and is not a member of the community' do + @community.remove_member @user + get :index, :profile => @community.identifier + assert_tag :a, :attributes => {:class => 'button icon-menu-mail'} + end + + should 'display *report* button when the user is logged in and is not a member of the community' do + @community.remove_member @user + get :index, :profile => @community.identifier + assert_tag :a, :attributes => {:class => 'button icon-alert report-abuse-action'} + end + + + # USER LOGGED IN AND COMMUNITY ADMIN + + should 'display *configure* button when the user is logged in and is community admin' do + get :index, :profile => @community.identifier + assert_tag :a, :attributes => {:class => 'button icon-menu-ctrl-panel'} + end + + + # USER NOT LOGGED IN + + should 'not display *send email to administrators* button when the user is not logged in' do + logout + get :index, :profile => @community.identifier + assert_no_tag :a, :attributes => {:class => 'button icon-menu-mail'} + end + + should 'not display *report* button when the user is not logged in' do + logout + get :index, :profile => @community.identifier + assert_no_tag :a, :attributes => {:class => 'button icon-alert report-abuse-action'} + end + + should 'not display *configure* button when the user is logged in and is admin of the community' do + logout + get :index, :profile => @community.identifier + assert_no_tag :a, :attributes => {:class => 'button icon-menu-ctrl-panel link-this-page'} end end diff --git a/plugins/community_block/views/community_block.rhtml b/plugins/community_block/views/community_block.rhtml index fd4bae6..310d48f 100644 --- a/plugins/community_block/views/community_block.rhtml +++ b/plugins/community_block/views/community_block.rhtml @@ -5,34 +5,58 @@