La gestion des notes de modération est en place, sans l'envoi de mail

This commit is contained in:
echarp 2014-03-06 21:49:30 +01:00
parent c989a6aea3
commit b1f1b00f79
7 changed files with 31 additions and 36 deletions

View File

@ -145,7 +145,7 @@ table.calendar
a a
color: #8F4900 color: #8F4900
.events form .events form, .moderations form
.field, .actions .field, .actions
text-align: left text-align: left
margin-left: 2px margin-left: 2px

View File

@ -9,6 +9,8 @@
padding-bottom: 0.5em padding-bottom: 0.5em
&.empty &.empty
background-color: white background-color: white
&.note
text-align: left
pre pre
width: 70% width: 70%
margin: auto margin: auto

View File

@ -1,9 +1,19 @@
class NotesController < InheritedResources::Base 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 private
def begin_of_association_chain def begin_of_association_chain
@event = Event.unscoped.find params[:moderation_id] @moderation = Event.unscoped.find params[:moderation_id]
@event = @moderation
end end
def permitted_params def permitted_params

View File

@ -1,4 +1,9 @@
class Note < ActiveRecord::Base class Note < ActiveRecord::Base
belongs_to :event belongs_to :event
belongs_to :author, class_name: User 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 end

View File

@ -45,7 +45,7 @@
- event.notes.each do |note| - event.notes.each do |note|
%tr %tr
%td.empty/ %td.empty/
%td(colspan="5") %td.note(colspan="5")
=raw note.contents =raw note.contents
%em.author %em.author
=t '.posted_by', =t '.posted_by',

View File

@ -1,6 +1,5 @@
%h3 %h3
= link_to t('.back'), moderations_path = link_to t('.back'), moderations_path
>>>
=t '.title' =t '.title'
.box= render 'form' .box= render 'form'

View File

@ -1,49 +1,28 @@
require 'test_helper' require 'test_helper'
class NotesControllerTest < ActionController::TestCase class NotesControllerTest < ActionController::TestCase
include Devise::TestHelpers
setup do setup do
@note = notes(:one) @note = notes(:one)
end
test "should get index" do sign_in users(:one)
get :index
assert_response :success
assert_not_nil assigns(:notes)
end end
test "should get new" do test "should get new" do
get :new get :new, moderation_id: @note.event.id
assert_response :success assert_response :success
end end
test "should create note" do test "should create note" do
assert_difference('Note.count') 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 end
assert_redirected_to note_path(assigns(:note)) assert_redirected_to moderations_path
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
end end
end end