lint this, check todo
This commit is contained in:
@@ -48,7 +48,7 @@ class Admin::RequestsController < Admin::BaseController
|
|||||||
@entry = Entry.find(params[:id])
|
@entry = Entry.find(params[:id])
|
||||||
@user = @entry.requested_by
|
@user = @entry.requested_by
|
||||||
|
|
||||||
entry_preview = [@entry.fi, @entry.en, @entry.sv, @entry.no, @entry.ru, @entry.de].compact.first || "Entry"
|
entry_preview = [ @entry.fi, @entry.en, @entry.sv, @entry.no, @entry.ru, @entry.de ].compact.first || "Entry"
|
||||||
|
|
||||||
@entry.destroy!
|
@entry.destroy!
|
||||||
@user.destroy! if @user.requested_entries.count.zero?
|
@user.destroy! if @user.requested_entries.count.zero?
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ class Entry < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def at_least_one_translation
|
def at_least_one_translation
|
||||||
if [fi, en, sv, no, ru, de].all?(&:blank?)
|
if [ fi, en, sv, no, ru, de ].all?(&:blank?)
|
||||||
errors.add(:base, "At least one language translation is required")
|
errors.add(:base, "At least one language translation is required")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ Rails.application.routes.draw do
|
|||||||
patch "invitations/:token/accept", to: "invitations#update", as: :accept_invitation
|
patch "invitations/:token/accept", to: "invitations#update", as: :accept_invitation
|
||||||
|
|
||||||
# Public entry request routes
|
# Public entry request routes
|
||||||
resources :requests, only: [:new, :create]
|
resources :requests, only: [ :new, :create ]
|
||||||
|
|
||||||
# Admin namespace
|
# Admin namespace
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@
|
|||||||
- [ ] **Notifications** when suggestions are reviewed
|
- [ ] **Notifications** when suggestions are reviewed
|
||||||
|
|
||||||
### Comments & Discussion
|
### Comments & Discussion
|
||||||
- [ ] **Add comment** form on entry view
|
- [x] **Add comment** form on entry view
|
||||||
- [ ] **Edit/delete own comments**
|
- [ ] **Edit/delete own comments**
|
||||||
- [ ] **Comment threading** (optional: replies to comments)
|
- [ ] **Comment threading** (optional: replies to comments)
|
||||||
- [ ] **Comment notifications** for entry contributors
|
- [ ] **Comment notifications** for entry contributors
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class RequestsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "should create entry request with valid data" do
|
test "should create entry request with valid data" do
|
||||||
assert_difference(["User.count", "Entry.count"], 1) do
|
assert_difference([ "User.count", "Entry.count" ], 1) do
|
||||||
post requests_path, params: {
|
post requests_path, params: {
|
||||||
entry: {
|
entry: {
|
||||||
name: "New Requester",
|
name: "New Requester",
|
||||||
@@ -52,7 +52,7 @@ class RequestsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "should require at least one translation" do
|
test "should require at least one translation" do
|
||||||
assert_no_difference(["User.count", "Entry.count"]) do
|
assert_no_difference([ "User.count", "Entry.count" ]) do
|
||||||
post requests_path, params: {
|
post requests_path, params: {
|
||||||
entry: {
|
entry: {
|
||||||
name: "New Requester",
|
name: "New Requester",
|
||||||
@@ -70,7 +70,7 @@ class RequestsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
test "should redirect to login if email already exists" do
|
test "should redirect to login if email already exists" do
|
||||||
existing_user = users(:contributor_user)
|
existing_user = users(:contributor_user)
|
||||||
|
|
||||||
assert_no_difference(["User.count", "Entry.count"]) do
|
assert_no_difference([ "User.count", "Entry.count" ]) do
|
||||||
post requests_path, params: {
|
post requests_path, params: {
|
||||||
entry: {
|
entry: {
|
||||||
name: "Test User",
|
name: "Test User",
|
||||||
@@ -96,7 +96,7 @@ class RequestsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "should create entry with only one translation" do
|
test "should create entry with only one translation" do
|
||||||
assert_difference(["User.count", "Entry.count"], 1) do
|
assert_difference([ "User.count", "Entry.count" ], 1) do
|
||||||
post requests_path, params: {
|
post requests_path, params: {
|
||||||
entry: {
|
entry: {
|
||||||
name: "Single Translation",
|
name: "Single Translation",
|
||||||
@@ -115,7 +115,7 @@ class RequestsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "should create entry with multiple translations" do
|
test "should create entry with multiple translations" do
|
||||||
assert_difference(["User.count", "Entry.count"], 1) do
|
assert_difference([ "User.count", "Entry.count" ], 1) do
|
||||||
post requests_path, params: {
|
post requests_path, params: {
|
||||||
entry: {
|
entry: {
|
||||||
name: "Multi Lingual",
|
name: "Multi Lingual",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require "test_helper"
|
|||||||
class EntryRequestFlowTest < ActionDispatch::IntegrationTest
|
class EntryRequestFlowTest < ActionDispatch::IntegrationTest
|
||||||
test "complete flow: request -> admin approve -> user accepts -> entry active" do
|
test "complete flow: request -> admin approve -> user accepts -> entry active" do
|
||||||
# Step 1: Public user submits entry request
|
# Step 1: Public user submits entry request
|
||||||
assert_difference(["User.count", "Entry.count"], 1) do
|
assert_difference([ "User.count", "Entry.count" ], 1) do
|
||||||
post requests_path, params: {
|
post requests_path, params: {
|
||||||
entry: {
|
entry: {
|
||||||
name: "Flow Test User",
|
name: "Flow Test User",
|
||||||
@@ -110,7 +110,7 @@ class EntryRequestFlowTest < ActionDispatch::IntegrationTest
|
|||||||
# Admin rejects it
|
# Admin rejects it
|
||||||
login_as(users(:admin_user))
|
login_as(users(:admin_user))
|
||||||
|
|
||||||
assert_difference(["User.count", "Entry.count"], -1) do
|
assert_difference([ "User.count", "Entry.count" ], -1) do
|
||||||
delete reject_admin_request_path(entry)
|
delete reject_admin_request_path(entry)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user