diff --git a/app/controllers/moderation/comments_controller.rb b/app/controllers/moderation/comments_controller.rb
index 6434c708e..8a4d3768e 100644
--- a/app/controllers/moderation/comments_controller.rb
+++ b/app/controllers/moderation/comments_controller.rb
@@ -19,8 +19,8 @@ class Moderation::CommentsController < Moderation::BaseController
redirect_to request.query_parameters.merge(action: :index)
end
- def mark_as_reviewed
- @comment.mark_as_reviewed
+ def archive
+ @comment.archive
redirect_to request.query_parameters.merge(action: :index)
end
@@ -31,7 +31,7 @@ class Moderation::CommentsController < Moderation::BaseController
end
def set_valid_filters
- @valid_filters = %w{all pending_review archived}
+ @valid_filters = %w{all pending archived}
end
def parse_filter
diff --git a/app/controllers/moderation/debates_controller.rb b/app/controllers/moderation/debates_controller.rb
index 89360ddaa..3492ee423 100644
--- a/app/controllers/moderation/debates_controller.rb
+++ b/app/controllers/moderation/debates_controller.rb
@@ -19,8 +19,8 @@ class Moderation::DebatesController < Moderation::BaseController
redirect_to request.query_parameters.merge(action: :index)
end
- def mark_as_reviewed
- @debate.mark_as_reviewed
+ def archive
+ @debate.archive
redirect_to request.query_parameters.merge(action: :index)
end
@@ -31,7 +31,7 @@ class Moderation::DebatesController < Moderation::BaseController
end
def set_valid_filters
- @valid_filters = %w{all pending_review archived}
+ @valid_filters = %w{all pending archived}
end
def parse_filter
diff --git a/app/models/ability.rb b/app/models/ability.rb
index a29f09a60..c8ed63d22 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -53,14 +53,14 @@ class Ability
can :hide, Comment, hidden_at: nil
cannot :hide, Comment, user_id: user.id
- can :mark_as_reviewed, Comment, reviewed_at: nil, hidden_at: nil
- cannot :mark_as_reviewed, Comment, user_id: user.id
+ can :archive, Comment, archived_at: nil, hidden_at: nil
+ cannot :archive, Comment, user_id: user.id
can :hide, Debate, hidden_at: nil
cannot :hide, Debate, author_id: user.id
- can :mark_as_reviewed, Debate, reviewed_at: nil, hidden_at: nil
- cannot :mark_as_reviewed, Debate, author_id: user.id
+ can :archive, Debate, archived_at: nil, hidden_at: nil
+ cannot :archive, Debate, author_id: user.id
can :hide, User
cannot :hide, User, id: user.id
diff --git a/app/models/comment.rb b/app/models/comment.rb
index 0fa84dc6e..2f69138d7 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -18,8 +18,8 @@ class Comment < ActiveRecord::Base
scope :recent, -> { order(id: :desc) }
scope :sorted_for_moderation, -> { order(inappropiate_flags_count: :desc, updated_at: :desc) }
- scope :pending_review, -> { where(reviewed_at: nil, hidden_at: nil) }
- scope :archived, -> { where("reviewed_at IS NOT NULL AND hidden_at IS NULL") }
+ scope :pending, -> { where(archived_at: nil, hidden_at: nil) }
+ scope :archived, -> { where("archived_at IS NOT NULL AND hidden_at IS NULL") }
scope :flagged_as_inappropiate, -> { where("inappropiate_flags_count > 0") }
def self.build(commentable, user, body)
@@ -56,8 +56,8 @@ class Comment < ActiveRecord::Base
hidden? || user.hidden?
end
- def reviewed?
- reviewed_at.present?
+ def archived?
+ archived_at.present?
end
def as_administrator?
@@ -68,8 +68,8 @@ class Comment < ActiveRecord::Base
moderator_id.present?
end
- def mark_as_reviewed
- update(reviewed_at: Time.now)
+ def archive
+ update(archived_at: Time.now)
end
# TODO: faking counter cache since there is a bug with acts_as_nested_set :counter_cache
diff --git a/app/models/debate.rb b/app/models/debate.rb
index e31a82a85..c20245e85 100644
--- a/app/models/debate.rb
+++ b/app/models/debate.rb
@@ -24,8 +24,8 @@ class Debate < ActiveRecord::Base
before_validation :sanitize_tag_list
scope :sorted_for_moderation, -> { order(inappropiate_flags_count: :desc, updated_at: :desc) }
- scope :pending_review, -> { where(reviewed_at: nil, hidden_at: nil) }
- scope :archived, -> { where("reviewed_at IS NOT NULL AND hidden_at IS NULL") }
+ scope :pending, -> { where(archived_at: nil, hidden_at: nil) }
+ scope :archived, -> { where("archived_at IS NOT NULL AND hidden_at IS NULL") }
scope :flagged_as_inappropiate, -> { where("inappropiate_flags_count > 0") }
# Ahoy setup
@@ -74,12 +74,12 @@ class Debate < ActiveRecord::Base
count < 0 ? 0 : count
end
- def reviewed?
- reviewed_at.present?
+ def archived?
+ archived_at.present?
end
- def mark_as_reviewed
- update(reviewed_at: Time.now)
+ def archive
+ update(archived_at: Time.now)
end
protected
diff --git a/app/views/moderation/comments/index.html.erb b/app/views/moderation/comments/index.html.erb
index 02b503497..f4ce8ec67 100644
--- a/app/views/moderation/comments/index.html.erb
+++ b/app/views/moderation/comments/index.html.erb
@@ -39,12 +39,12 @@
<%= link_to t("moderation.comments.index.hide"), hide_in_moderation_screen_moderation_comment_path(comment, request.query_parameters), method: :put, class: "delete" %>
|
- <% if can? :mark_as_reviewed, comment %>
+ <% if can? :archive, comment %>
- <%= link_to t("moderation.comments.index.archive"), mark_as_reviewed_moderation_comment_path(comment, request.query_parameters), method: :put, class: "button radius tiny warning" %>
+ <%= link_to t("moderation.comments.index.archive"), archive_moderation_comment_path(comment, request.query_parameters), method: :put, class: "button radius tiny warning" %>
|
<% end %>
- <% if comment.reviewed? %>
+ <% if comment.archived? %>
<%= t("moderation.comments.index.archived") %>
|
diff --git a/app/views/moderation/debates/index.html.erb b/app/views/moderation/debates/index.html.erb
index 68de5807d..ac11d2159 100644
--- a/app/views/moderation/debates/index.html.erb
+++ b/app/views/moderation/debates/index.html.erb
@@ -38,12 +38,12 @@
<%= link_to t("moderation.debates.index.hide"), hide_in_moderation_screen_moderation_debate_path(debate, request.query_parameters), method: :put, class: "delete" %>
|
- <% if can? :mark_as_reviewed, debate %>
+ <% if can? :archive, debate %>
- <%= link_to t("moderation.debates.index.archive"), mark_as_reviewed_moderation_debate_path(debate, request.query_parameters), method: :put, class: "button radius tiny warning" %>
+ <%= link_to t("moderation.debates.index.archive"), archive_moderation_debate_path(debate, request.query_parameters), method: :put, class: "button radius tiny warning" %>
|
<% end %>
- <% if debate.reviewed? %>
+ <% if debate.archived? %>
<%= t("moderation.debates.index.archived") %>
|
diff --git a/config/locales/moderation.en.yml b/config/locales/moderation.en.yml
index 7688dfa09..3d61c93a2 100644
--- a/config/locales/moderation.en.yml
+++ b/config/locales/moderation.en.yml
@@ -21,7 +21,7 @@ en:
filter: Filter
filters:
all: All
- pending_review: Pending
+ pending: Pending
archived: Archived
debates:
index:
@@ -38,5 +38,5 @@ en:
filter: Filter
filters:
all: All
- pending_review: Pending
+ pending: Pending
archived: Archived
diff --git a/config/locales/moderation.es.yml b/config/locales/moderation.es.yml
index 61d6b5f5c..73886ddb0 100644
--- a/config/locales/moderation.es.yml
+++ b/config/locales/moderation.es.yml
@@ -21,7 +21,7 @@ es:
filter: Filtrar
filters:
all: Todos
- pending_review: Pendientes
+ pending: Pendientes
archived: Archivados
debates:
index:
@@ -38,5 +38,5 @@ es:
filter: Filtrar
filters:
all: Todos
- pending_review: Pendientes
+ pending: Pendientes
archived: Archivados
diff --git a/config/routes.rb b/config/routes.rb
index 1e8b860a0..3a75c8634 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -88,7 +88,7 @@ Rails.application.routes.draw do
member do
put :hide
put :hide_in_moderation_screen
- put :mark_as_reviewed
+ put :archive
end
end
@@ -96,7 +96,7 @@ Rails.application.routes.draw do
member do
put :hide
put :hide_in_moderation_screen
- put :mark_as_reviewed
+ put :archive
end
end
end
diff --git a/db/migrate/20150826112411_rename_reviewed_at_to_archived_at_in_comments_and_debates.rb b/db/migrate/20150826112411_rename_reviewed_at_to_archived_at_in_comments_and_debates.rb
new file mode 100644
index 000000000..86bebd8e1
--- /dev/null
+++ b/db/migrate/20150826112411_rename_reviewed_at_to_archived_at_in_comments_and_debates.rb
@@ -0,0 +1,6 @@
+class RenameReviewedAtToArchivedAtInCommentsAndDebates < ActiveRecord::Migration
+ def change
+ rename_column :comments, :reviewed_at, :archived_at
+ rename_column :debates, :reviewed_at, :archived_at
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index d21459719..7633cda01 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20150824144524) do
+ActiveRecord::Schema.define(version: 20150826112411) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -51,7 +51,7 @@ ActiveRecord::Schema.define(version: 20150824144524) do
t.datetime "hidden_at"
t.datetime "flagged_as_inappropiate_at"
t.integer "inappropiate_flags_count", default: 0
- t.datetime "reviewed_at"
+ t.datetime "archived_at"
t.integer "moderator_id"
t.integer "administrator_id"
end
@@ -70,7 +70,7 @@ ActiveRecord::Schema.define(version: 20150824144524) do
t.datetime "hidden_at"
t.datetime "flagged_as_inappropiate_at"
t.integer "inappropiate_flags_count", default: 0
- t.datetime "reviewed_at"
+ t.datetime "archived_at"
end
add_index "debates", ["hidden_at"], name: "index_debates_on_hidden_at", using: :btree
diff --git a/spec/factories.rb b/spec/factories.rb
index 4fa2a70e3..43a1bce85 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -22,8 +22,8 @@ FactoryGirl.define do
hidden_at Time.now
end
- trait :reviewed do
- reviewed_at Time.now
+ trait :archived do
+ archived_at Time.now
end
trait :flagged_as_inappropiate do
@@ -48,8 +48,8 @@ FactoryGirl.define do
hidden_at Time.now
end
- trait :reviewed do
- reviewed_at Time.now
+ trait :archived do
+ archived_at Time.now
end
trait :flagged_as_inappropiate do
diff --git a/spec/features/moderation/comments_spec.rb b/spec/features/moderation/comments_spec.rb
index ba40598d8..2e3d1196e 100644
--- a/spec/features/moderation/comments_spec.rb
+++ b/spec/features/moderation/comments_spec.rb
@@ -111,7 +111,7 @@ feature 'Moderate Comments' do
expect(page).to have_link('Pending')
expect(page).to have_link('Archived')
- visit moderation_comments_path(filter: 'pending_review')
+ visit moderation_comments_path(filter: 'pending')
expect(page).to have_link('All')
expect(page).to_not have_link('Pending')
expect(page).to have_link('Archived')
@@ -125,14 +125,14 @@ feature 'Moderate Comments' do
scenario "Filtering comments" do
create(:comment, :flagged_as_inappropiate, body: "Pending comment")
create(:comment, :flagged_as_inappropiate, :hidden, body: "Hidden comment")
- create(:comment, :flagged_as_inappropiate, :reviewed, body: "Archived comment")
+ create(:comment, :flagged_as_inappropiate, :archived, body: "Archived comment")
visit moderation_comments_path(filter: 'all')
expect(page).to have_content('Pending comment')
expect(page).to_not have_content('Hidden comment')
expect(page).to have_content('Archived comment')
- visit moderation_comments_path(filter: 'pending_review')
+ visit moderation_comments_path(filter: 'pending')
expect(page).to have_content('Pending comment')
expect(page).to_not have_content('Hidden comment')
expect(page).to_not have_content('Archived comment')
@@ -147,14 +147,14 @@ feature 'Moderate Comments' do
per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:comment, :flagged_as_inappropiate) }
- visit moderation_comments_path(filter: 'pending_review', page: 2)
+ visit moderation_comments_path(filter: 'pending', page: 2)
click_link('Archive', match: :first, exact: true)
uri = URI.parse(current_url)
query_params = Rack::Utils.parse_nested_query(uri.query).symbolize_keys
- expect(query_params[:filter]).to eq('pending_review')
+ expect(query_params[:filter]).to eq('pending')
expect(query_params[:page]).to eq('2')
end
@@ -187,7 +187,7 @@ feature 'Moderate Comments' do
expect(@comment.reload).to be_hidden
end
- scenario 'Marking the comment as reviewed' do
+ scenario 'Marking the comment as archived' do
within("#comment_#{@comment.id}") do
click_link('Archive')
end
@@ -198,7 +198,7 @@ feature 'Moderate Comments' do
expect(page).to have_content('Archived')
end
- expect(@comment.reload).to be_reviewed
+ expect(@comment.reload).to be_archived
end
end
end
diff --git a/spec/features/moderation/debates_spec.rb b/spec/features/moderation/debates_spec.rb
index d27a5b9fc..b1234bb1b 100644
--- a/spec/features/moderation/debates_spec.rb
+++ b/spec/features/moderation/debates_spec.rb
@@ -54,7 +54,7 @@ feature 'Moderate debates' do
expect(page).to have_link('Pending')
expect(page).to have_link('Archived')
- visit moderation_debates_path(filter: 'pending_review')
+ visit moderation_debates_path(filter: 'pending')
expect(page).to have_link('All')
expect(page).to_not have_link('Pending')
expect(page).to have_link('Archived')
@@ -68,14 +68,14 @@ feature 'Moderate debates' do
scenario "Filtering debates" do
create(:debate, :flagged_as_inappropiate, title: "Pending debate")
create(:debate, :flagged_as_inappropiate, :hidden, title: "Hidden debate")
- create(:debate, :flagged_as_inappropiate, :reviewed, title: "Archived debate")
+ create(:debate, :flagged_as_inappropiate, :archived, title: "Archived debate")
visit moderation_debates_path(filter: 'all')
expect(page).to have_content('Pending debate')
expect(page).to_not have_content('Hidden debate')
expect(page).to have_content('Archived debate')
- visit moderation_debates_path(filter: 'pending_review')
+ visit moderation_debates_path(filter: 'pending')
expect(page).to have_content('Pending debate')
expect(page).to_not have_content('Hidden debate')
expect(page).to_not have_content('Archived debate')
@@ -90,14 +90,14 @@ feature 'Moderate debates' do
per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:debate, :flagged_as_inappropiate) }
- visit moderation_debates_path(filter: 'pending_review', page: 2)
+ visit moderation_debates_path(filter: 'pending', page: 2)
click_link('Archive', match: :first, exact: true)
uri = URI.parse(current_url)
query_params = Rack::Utils.parse_nested_query(uri.query).symbolize_keys
- expect(query_params[:filter]).to eq('pending_review')
+ expect(query_params[:filter]).to eq('pending')
expect(query_params[:page]).to eq('2')
end
@@ -129,7 +129,7 @@ feature 'Moderate debates' do
expect(@debate.reload).to be_hidden
end
- scenario 'Marking the debate as reviewed' do
+ scenario 'Marking the debate as archived' do
within("#debate_#{@debate.id}") do
click_link('Archive')
end
@@ -140,7 +140,7 @@ feature 'Moderate debates' do
expect(page).to have_content('Archived')
end
- expect(@debate.reload).to be_reviewed
+ expect(@debate.reload).to be_archived
end
end
end
diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb
index ff3e3800c..a7cfd195f 100644
--- a/spec/models/ability_spec.rb
+++ b/spec/models/ability_spec.rb
@@ -131,8 +131,8 @@ describe Ability do
let(:own_debate) { create(:debate, author: user) }
let(:hidden_comment) { create(:comment, :hidden) }
let(:hidden_debate) { create(:debate, :hidden) }
- let(:reviewed_comment) { create(:comment, :reviewed) }
- let(:reviewed_debate) { create(:debate, :reviewed) }
+ let(:archived_comment) { create(:comment, :archived) }
+ let(:archived_debate) { create(:debate, :archived) }
it { should be_able_to(:hide, comment) }
it { should be_able_to(:hide_in_moderation_screen, comment) }
@@ -144,15 +144,15 @@ describe Ability do
it { should_not be_able_to(:hide, hidden_debate) }
it { should_not be_able_to(:hide, own_debate) }
- it { should be_able_to(:mark_as_reviewed, comment) }
- it { should_not be_able_to(:mark_as_reviewed, hidden_comment) }
- it { should_not be_able_to(:mark_as_reviewed, reviewed_comment) }
- it { should_not be_able_to(:mark_as_reviewed, own_comment) }
+ it { should be_able_to(:archive, comment) }
+ it { should_not be_able_to(:archive, hidden_comment) }
+ it { should_not be_able_to(:archive, archived_comment) }
+ it { should_not be_able_to(:archive, own_comment) }
- it { should be_able_to(:mark_as_reviewed, debate) }
- it { should_not be_able_to(:mark_as_reviewed, hidden_debate) }
- it { should_not be_able_to(:mark_as_reviewed, reviewed_debate) }
- it { should_not be_able_to(:mark_as_reviewed, own_debate) }
+ it { should be_able_to(:archive, debate) }
+ it { should_not be_able_to(:archive, hidden_debate) }
+ it { should_not be_able_to(:archive, archived_debate) }
+ it { should_not be_able_to(:archive, own_debate) }
it { should_not be_able_to(:hide, user) }
it { should be_able_to(:hide, other_user) }