diff --git a/app/assets/javascripts/moderator_comment.js.coffee b/app/assets/javascripts/moderator_comment.js.coffee
index 7cc680169..fcc6e92c1 100644
--- a/app/assets/javascripts/moderator_comment.js.coffee
+++ b/app/assets/javascripts/moderator_comment.js.coffee
@@ -4,4 +4,4 @@ App.ModeratorComments =
$("##{id} .comment-body:first").addClass("faded")
hide_moderator_actions: (id) ->
- $("##{id} #moderator-comment-actions:first").hide()
\ No newline at end of file
+ $("##{id} .js-moderator-comment-actions").hide()
diff --git a/app/assets/javascripts/moderator_debates.js.coffee b/app/assets/javascripts/moderator_debates.js.coffee
index 802504ec2..7cb25eb51 100644
--- a/app/assets/javascripts/moderator_debates.js.coffee
+++ b/app/assets/javascripts/moderator_debates.js.coffee
@@ -5,4 +5,4 @@ App.ModeratorDebates =
$("#comments").addClass("faded")
hide_moderator_actions: (id) ->
- $("##{id} #moderator-debate-actions:first").hide()
\ No newline at end of file
+ $("##{id} .js-moderator-debate-actions:first").hide()
diff --git a/app/views/comments/_actions.html.erb b/app/views/comments/_actions.html.erb
index 8cc1b114f..5454179f0 100644
--- a/app/views/comments/_actions.html.erb
+++ b/app/views/comments/_actions.html.erb
@@ -1,10 +1,13 @@
-
diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb
index 9e1c8485c..ca7474ebd 100644
--- a/app/views/comments/_comment.html.erb
+++ b/app/views/comments/_comment.html.erb
@@ -89,9 +89,7 @@
<%= link_to(comment_link_text(comment), "",
class: "js-add-comment-link", data: {'id': dom_id(comment)}) %>
- <% if moderator? %>
- <%= render 'comments/actions', comment: comment %>
- <% end %>
+ <%= render 'comments/actions', comment: comment %>
<%= render 'comments/form', {parent: comment, toggeable: true} %>
<% end %>
diff --git a/app/views/debates/_actions.html.erb b/app/views/debates/_actions.html.erb
index 5a51749dc..db9821ad0 100644
--- a/app/views/debates/_actions.html.erb
+++ b/app/views/debates/_actions.html.erb
@@ -1,7 +1,9 @@
-<%= link_to t("admin.actions.hide").capitalize, hide_moderation_debate_path(debate),
- method: :put, remote: true, data: { confirm: t('admin.actions.confirm') } %>
+<% if can? :hide, debate %>
+ <%= link_to t("admin.actions.hide").capitalize, hide_moderation_debate_path(debate),
+ method: :put, remote: true, data: { confirm: t('admin.actions.confirm') } %>
+<% end %>
-<% unless debate.author.hidden? %>
+<% if can? :hide, debate.author %>
|
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(debate.author_id),
method: :put, data: { confirm: t('admin.actions.confirm') } %>
diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb
index 2c69e79f7..47ff9e34f 100644
--- a/app/views/debates/show.html.erb
+++ b/app/views/debates/show.html.erb
@@ -52,7 +52,7 @@
<%= render 'shared/tags', debate: @debate %>
<% if moderator? %>
-
+
<%= render 'actions', debate: @debate %>
<% end %>
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 63168eb28..acf67286d 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -42,4 +42,6 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
+
+ config.cache_store = :null_store
end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 76ec52249..e84606f73 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -55,7 +55,7 @@ Rails.application.configure do
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
- # config.cache_store = :mem_cache_store
+ config.cache_store = :null_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
diff --git a/config/environments/staging.rb b/config/environments/staging.rb
index 76ec52249..e84606f73 100644
--- a/config/environments/staging.rb
+++ b/config/environments/staging.rb
@@ -55,7 +55,7 @@ Rails.application.configure do
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
- # config.cache_store = :mem_cache_store
+ config.cache_store = :null_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 34034499f..a76376fe6 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -43,4 +43,6 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
+
+ config.cache_store = :null_store
end
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 871cc023c..1e2cca785 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -147,4 +147,4 @@ es:
manage:
all: "No tienes permiso para realizar la acción '%{action}' sobre %{subject}."
welcome:
- last_debates: Úlitmos debates
+ last_debates: Últimos debates
diff --git a/spec/features/comments_spec.rb b/spec/features/comments_spec.rb
index 39babcda7..4ed16d915 100644
--- a/spec/features/comments_spec.rb
+++ b/spec/features/comments_spec.rb
@@ -286,4 +286,4 @@ feature 'Comments' do
end
end
-end
+end
\ No newline at end of file
diff --git a/spec/features/moderation/comments_spec.rb b/spec/features/moderation/comments_spec.rb
index e52a87c17..5a4100f77 100644
--- a/spec/features/moderation/comments_spec.rb
+++ b/spec/features/moderation/comments_spec.rb
@@ -59,17 +59,38 @@ feature 'Moderate Comments' do
moderator = create(:moderator)
debate = create(:debate)
- create(:comment, commentable: debate)
+ comment = create(:comment, commentable: debate)
login_as(moderator.user)
visit debate_path(debate)
- expect(page).to have_css("#moderator-comment-actions")
+ within "#comment_#{comment.id}" do
+ expect(page).to have_link("Hide")
+ expect(page).to have_link("Ban author")
+ end
login_as(citizen)
visit debate_path(debate)
- expect(page).to_not have_css("#moderator-comment-actions")
+ within "#comment_#{comment.id}" do
+ expect(page).to_not have_link("Hide")
+ expect(page).to_not have_link("Ban author")
+ end
+ end
+
+ scenario 'Moderator actions do not appear in own comments' do
+ moderator = create(:moderator)
+
+ debate = create(:debate)
+ comment = create(:comment, commentable: debate, user: moderator.user)
+
+ login_as(moderator.user)
+ visit debate_path(debate)
+
+ within "#comment_#{comment.id}" do
+ expect(page).to_not have_link("Hide")
+ expect(page).to_not have_link("Ban author")
+ end
end
feature '/moderation/ menu' do
diff --git a/spec/features/moderation/debates_spec.rb b/spec/features/moderation/debates_spec.rb
index bb2b58c24..1ea3101e0 100644
--- a/spec/features/moderation/debates_spec.rb
+++ b/spec/features/moderation/debates_spec.rb
@@ -23,6 +23,19 @@ feature 'Moderate debates' do
expect(page).to have_css('.debate', count: 0)
end
+ scenario 'Can not hide own debate' do
+ moderator = create(:moderator)
+ debate = create(:debate, author: moderator.user)
+
+ login_as(moderator.user)
+ visit debate_path(debate)
+
+ within("#debate_#{debate.id}") do
+ expect(page).to_not have_link('Hide')
+ expect(page).to_not have_link('Block author')
+ end
+ end
+
feature '/moderation/ menu' do
background do