logs activity: restore admin actions

on User/Proposal/Debate/Comment
This commit is contained in:
Juanjo Bazán
2015-09-22 17:24:13 +02:00
parent 6082f77ec2
commit 02b1e30205
6 changed files with 82 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ class Admin::CommentsController < Admin::BaseController
def restore
@comment.restore
Activity.log(current_user, :restore, @comment)
redirect_to request.query_parameters.merge(action: :index)
end

View File

@@ -14,6 +14,7 @@ class Admin::DebatesController < Admin::BaseController
def restore
@debate.restore
Activity.log(current_user, :restore, @debate)
redirect_to request.query_parameters.merge(action: :index)
end

View File

@@ -14,6 +14,7 @@ class Admin::ProposalsController < Admin::BaseController
def restore
@proposal.restore
Activity.log(current_user, :restore, @proposal)
redirect_to request.query_parameters.merge(action: :index)
end

View File

@@ -20,6 +20,7 @@ class Admin::UsersController < Admin::BaseController
def restore
@user.restore
Activity.log(current_user, :restore, @user)
redirect_to request.query_parameters.merge(action: :index)
end

View File

@@ -6,7 +6,7 @@
<ul class="admin-list">
<% @users.each do |user| %>
<li>
<li id="<%= dom_id(user) %>">
<%= link_to user.name, admin_user_path(user) %>
<%= link_to t("admin.actions.restore"),

View File

@@ -21,6 +21,7 @@ feature 'Admin activity' do
within("#activity_#{Activity.last.id}") do
expect(page).to have_content(proposal.title)
expect(page).to have_content("Hidden")
expect(page).to have_content(@admin.user.username)
end
end
@@ -44,11 +45,28 @@ feature 'Admin activity' do
visit admin_activity_path
expect(page).to have_content(proposal1.title)
expect(page).to_not have_content(proposal2.title)
expect(page).to have_content(proposal3.title)
end
scenario "Shows admin restores" do
proposal = create(:proposal, :hidden)
visit admin_proposals_path
within("#proposal_#{proposal.id}") do
click_on "Restore"
end
visit admin_activity_path
within("#activity_#{Activity.last.id}") do
expect(page).to have_content(proposal.title)
expect(page).to have_content("Restored")
expect(page).to have_content(@admin.user.username)
end
end
end
context "Debates" do
@@ -65,6 +83,7 @@ feature 'Admin activity' do
within("#activity_#{Activity.last.id}") do
expect(page).to have_content(debate.title)
expect(page).to have_content("Hidden")
expect(page).to have_content(@admin.user.username)
end
end
@@ -88,11 +107,28 @@ feature 'Admin activity' do
visit admin_activity_path
expect(page).to have_content(debate1.title)
expect(page).to_not have_content(debate2.title)
expect(page).to have_content(debate3.title)
end
scenario "Shows admin restores" do
debate = create(:debate, :hidden)
visit admin_debates_path
within("#debate_#{debate.id}") do
click_on "Restore"
end
visit admin_activity_path
within("#activity_#{Activity.last.id}") do
expect(page).to have_content(debate.title)
expect(page).to have_content("Restored")
expect(page).to have_content(@admin.user.username)
end
end
end
context "Comments" do
@@ -110,6 +146,7 @@ feature 'Admin activity' do
within("#activity_#{Activity.last.id}") do
expect(page).to have_content(comment.body)
expect(page).to have_content("Hidden")
expect(page).to have_content(@admin.user.username)
end
end
@@ -133,11 +170,28 @@ feature 'Admin activity' do
visit admin_activity_path
expect(page).to have_content(comment1.body)
expect(page).to_not have_content(comment2.body)
expect(page).to have_content(comment3.body)
end
scenario "Shows admin restores" do
comment = create(:comment, :hidden)
visit admin_comments_path
within("#comment_#{comment.id}") do
click_on "Restore"
end
visit admin_activity_path
within("#activity_#{Activity.last.id}") do
expect(page).to have_content(comment.body)
expect(page).to have_content("Restored")
expect(page).to have_content(@admin.user.username)
end
end
end
context "User" do
@@ -153,6 +207,7 @@ feature 'Admin activity' do
visit admin_activity_path
within("#activity_#{Activity.last.id}") do
expect(page).to have_content("Blocked")
expect(page).to have_content(proposal.author.username)
expect(page).to have_content(proposal.author.email)
expect(page).to have_content(@admin.user.username)
@@ -255,6 +310,25 @@ feature 'Admin activity' do
expect(page).to have_content(comment3.author.email)
expect(page).to_not have_content(comment2.author.username)
end
scenario "Shows admin restores" do
user = create(:user, :hidden)
visit admin_users_path
within("#user_#{user.id}") do
click_on "Restore"
end
visit admin_activity_path
within("#activity_#{Activity.last.id}") do
expect(page).to have_content(user.username)
expect(page).to have_content(user.email)
expect(page).to have_content("Restored")
expect(page).to have_content(@admin.user.username)
end
end
end
end