logs activity: restore admin actions
on User/Proposal/Debate/Comment
This commit is contained in:
@@ -14,6 +14,7 @@ class Admin::CommentsController < Admin::BaseController
|
|||||||
|
|
||||||
def restore
|
def restore
|
||||||
@comment.restore
|
@comment.restore
|
||||||
|
Activity.log(current_user, :restore, @comment)
|
||||||
redirect_to request.query_parameters.merge(action: :index)
|
redirect_to request.query_parameters.merge(action: :index)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class Admin::DebatesController < Admin::BaseController
|
|||||||
|
|
||||||
def restore
|
def restore
|
||||||
@debate.restore
|
@debate.restore
|
||||||
|
Activity.log(current_user, :restore, @debate)
|
||||||
redirect_to request.query_parameters.merge(action: :index)
|
redirect_to request.query_parameters.merge(action: :index)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class Admin::ProposalsController < Admin::BaseController
|
|||||||
|
|
||||||
def restore
|
def restore
|
||||||
@proposal.restore
|
@proposal.restore
|
||||||
|
Activity.log(current_user, :restore, @proposal)
|
||||||
redirect_to request.query_parameters.merge(action: :index)
|
redirect_to request.query_parameters.merge(action: :index)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class Admin::UsersController < Admin::BaseController
|
|||||||
|
|
||||||
def restore
|
def restore
|
||||||
@user.restore
|
@user.restore
|
||||||
|
Activity.log(current_user, :restore, @user)
|
||||||
redirect_to request.query_parameters.merge(action: :index)
|
redirect_to request.query_parameters.merge(action: :index)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<ul class="admin-list">
|
<ul class="admin-list">
|
||||||
<% @users.each do |user| %>
|
<% @users.each do |user| %>
|
||||||
<li>
|
<li id="<%= dom_id(user) %>">
|
||||||
<%= link_to user.name, admin_user_path(user) %>
|
<%= link_to user.name, admin_user_path(user) %>
|
||||||
|
|
||||||
<%= link_to t("admin.actions.restore"),
|
<%= link_to t("admin.actions.restore"),
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ feature 'Admin activity' do
|
|||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
within("#activity_#{Activity.last.id}") do
|
||||||
expect(page).to have_content(proposal.title)
|
expect(page).to have_content(proposal.title)
|
||||||
|
expect(page).to have_content("Hidden")
|
||||||
expect(page).to have_content(@admin.user.username)
|
expect(page).to have_content(@admin.user.username)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -44,11 +45,28 @@ feature 'Admin activity' do
|
|||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
|
|
||||||
expect(page).to have_content(proposal1.title)
|
expect(page).to have_content(proposal1.title)
|
||||||
expect(page).to_not have_content(proposal2.title)
|
expect(page).to_not have_content(proposal2.title)
|
||||||
expect(page).to have_content(proposal3.title)
|
expect(page).to have_content(proposal3.title)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context "Debates" do
|
context "Debates" do
|
||||||
@@ -65,6 +83,7 @@ feature 'Admin activity' do
|
|||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
within("#activity_#{Activity.last.id}") do
|
||||||
expect(page).to have_content(debate.title)
|
expect(page).to have_content(debate.title)
|
||||||
|
expect(page).to have_content("Hidden")
|
||||||
expect(page).to have_content(@admin.user.username)
|
expect(page).to have_content(@admin.user.username)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -88,11 +107,28 @@ feature 'Admin activity' do
|
|||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
|
|
||||||
expect(page).to have_content(debate1.title)
|
expect(page).to have_content(debate1.title)
|
||||||
expect(page).to_not have_content(debate2.title)
|
expect(page).to_not have_content(debate2.title)
|
||||||
expect(page).to have_content(debate3.title)
|
expect(page).to have_content(debate3.title)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context "Comments" do
|
context "Comments" do
|
||||||
@@ -110,6 +146,7 @@ feature 'Admin activity' do
|
|||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
within("#activity_#{Activity.last.id}") do
|
||||||
expect(page).to have_content(comment.body)
|
expect(page).to have_content(comment.body)
|
||||||
|
expect(page).to have_content("Hidden")
|
||||||
expect(page).to have_content(@admin.user.username)
|
expect(page).to have_content(@admin.user.username)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -133,11 +170,28 @@ feature 'Admin activity' do
|
|||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
|
|
||||||
expect(page).to have_content(comment1.body)
|
expect(page).to have_content(comment1.body)
|
||||||
expect(page).to_not have_content(comment2.body)
|
expect(page).to_not have_content(comment2.body)
|
||||||
expect(page).to have_content(comment3.body)
|
expect(page).to have_content(comment3.body)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context "User" do
|
context "User" do
|
||||||
@@ -153,6 +207,7 @@ feature 'Admin activity' do
|
|||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
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.username)
|
||||||
expect(page).to have_content(proposal.author.email)
|
expect(page).to have_content(proposal.author.email)
|
||||||
expect(page).to have_content(@admin.user.username)
|
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 have_content(comment3.author.email)
|
||||||
expect(page).to_not have_content(comment2.author.username)
|
expect(page).to_not have_content(comment2.author.username)
|
||||||
end
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user