La gestion des notes de modération est en place, sans l'envoi de mail
This commit is contained in:
parent
c989a6aea3
commit
b1f1b00f79
@ -145,7 +145,7 @@ table.calendar
|
||||
a
|
||||
color: #8F4900
|
||||
|
||||
.events form
|
||||
.events form, .moderations form
|
||||
.field, .actions
|
||||
text-align: left
|
||||
margin-left: 2px
|
||||
|
@ -9,6 +9,8 @@
|
||||
padding-bottom: 0.5em
|
||||
&.empty
|
||||
background-color: white
|
||||
&.note
|
||||
text-align: left
|
||||
pre
|
||||
width: 70%
|
||||
margin: auto
|
||||
|
@ -1,9 +1,19 @@
|
||||
class NotesController < InheritedResources::Base
|
||||
belongs_to :event
|
||||
belongs_to :moderation
|
||||
|
||||
def create
|
||||
create! do |format|
|
||||
format.html {
|
||||
@note.author = current_user
|
||||
create!(notice: 'Dude! Nice job creating that note.') { moderations_url }
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def begin_of_association_chain
|
||||
@event = Event.unscoped.find params[:moderation_id]
|
||||
@moderation = Event.unscoped.find params[:moderation_id]
|
||||
@event = @moderation
|
||||
end
|
||||
|
||||
def permitted_params
|
||||
|
@ -1,4 +1,9 @@
|
||||
class Note < ActiveRecord::Base
|
||||
belongs_to :event
|
||||
belongs_to :author, class_name: User
|
||||
|
||||
# Setup the magic time stamp so it uses the "date" column
|
||||
def timestamp_attributes_for_create
|
||||
super << :date
|
||||
end
|
||||
end
|
||||
|
@ -45,7 +45,7 @@
|
||||
- event.notes.each do |note|
|
||||
%tr
|
||||
%td.empty/
|
||||
%td(colspan="5")
|
||||
%td.note(colspan="5")
|
||||
=raw note.contents
|
||||
%em.author
|
||||
=t '.posted_by',
|
||||
|
@ -1,6 +1,5 @@
|
||||
%h3
|
||||
= link_to t('.back'), moderations_path
|
||||
>>>
|
||||
=t '.title'
|
||||
|
||||
.box= render 'form'
|
||||
|
@ -1,49 +1,28 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NotesControllerTest < ActionController::TestCase
|
||||
include Devise::TestHelpers
|
||||
|
||||
setup do
|
||||
@note = notes(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:notes)
|
||||
sign_in users(:one)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
get :new, moderation_id: @note.event.id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create note" do
|
||||
assert_difference('Note.count') do
|
||||
post :create, note: { author: @note.author, contents: @note.contents, date: @note.date, event: @note.event }
|
||||
post :create, moderation_id: @note.event.id, note: {
|
||||
author: @note.author,
|
||||
contents: @note.contents,
|
||||
date: @note.date
|
||||
}
|
||||
end
|
||||
|
||||
assert_redirected_to note_path(assigns(:note))
|
||||
end
|
||||
|
||||
test "should show note" do
|
||||
get :show, id: @note
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @note
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update note" do
|
||||
patch :update, id: @note, note: { author: @note.author, contents: @note.contents, date: @note.date, event: @note.event }
|
||||
assert_redirected_to note_path(assigns(:note))
|
||||
end
|
||||
|
||||
test "should destroy note" do
|
||||
assert_difference('Note.count', -1) do
|
||||
delete :destroy, id: @note
|
||||
end
|
||||
|
||||
assert_redirected_to notes_path
|
||||
assert_redirected_to moderations_path
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user