diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb
index ebe2f1066..3a9c360f5 100644
--- a/app/controllers/admin/comments_controller.rb
+++ b/app/controllers/admin/comments_controller.rb
@@ -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
diff --git a/app/controllers/admin/debates_controller.rb b/app/controllers/admin/debates_controller.rb
index 544c3f23d..41e5af848 100644
--- a/app/controllers/admin/debates_controller.rb
+++ b/app/controllers/admin/debates_controller.rb
@@ -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
diff --git a/app/controllers/admin/proposals_controller.rb b/app/controllers/admin/proposals_controller.rb
index 4f399bff7..57e8809e2 100644
--- a/app/controllers/admin/proposals_controller.rb
+++ b/app/controllers/admin/proposals_controller.rb
@@ -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
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index 013fe4e90..eed1c4fea 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -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
diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb
index b3c0ad40b..bb71fcd8f 100644
--- a/app/views/admin/users/index.html.erb
+++ b/app/views/admin/users/index.html.erb
@@ -6,7 +6,7 @@
<% @users.each do |user| %>
- -
+
-
<%= link_to user.name, admin_user_path(user) %>
<%= link_to t("admin.actions.restore"),
diff --git a/spec/features/admin/activity_spec.rb b/spec/features/admin/activity_spec.rb
index a029caedf..d2836b2d1 100644
--- a/spec/features/admin/activity_spec.rb
+++ b/spec/features/admin/activity_spec.rb
@@ -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
\ No newline at end of file