parent
6844cac3a0
commit
795b7f647c
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
@ -0,0 +1,4 @@
|
||||
.notes
|
||||
form
|
||||
label:after
|
||||
content: ':'
|
@ -0,0 +1,69 @@
|
||||
body {
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
font-family: verdana, arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
p, ol, ul, td {
|
||||
font-family: verdana, arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #eee;
|
||||
padding: 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #000;
|
||||
&:visited {
|
||||
color: #666;
|
||||
}
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background-color: #000;
|
||||
}
|
||||
}
|
||||
|
||||
div {
|
||||
&.field, &.actions {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
#notice {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.field_with_errors {
|
||||
padding: 2px;
|
||||
background-color: red;
|
||||
display: table;
|
||||
}
|
||||
|
||||
#error_explanation {
|
||||
width: 450px;
|
||||
border: 2px solid red;
|
||||
padding: 7px;
|
||||
padding-bottom: 0;
|
||||
margin-bottom: 20px;
|
||||
background-color: #f0f0f0;
|
||||
h2 {
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
padding: 5px 5px 5px 15px;
|
||||
font-size: 12px;
|
||||
margin: -7px;
|
||||
margin-bottom: 0px;
|
||||
background-color: #c00;
|
||||
color: #fff;
|
||||
}
|
||||
ul li {
|
||||
font-size: 12px;
|
||||
list-style: square;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
class NotesController < InheritedResources::Base
|
||||
belongs_to :event
|
||||
|
||||
private
|
||||
def begin_of_association_chain
|
||||
@event = Event.unscoped.find params[:moderation_id]
|
||||
end
|
||||
|
||||
def permitted_params
|
||||
params.permit note: [:contents]
|
||||
end
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module NotesHelper
|
||||
end
|
@ -0,0 +1,13 @@
|
||||
= form_for [:moderation, @note] do |f|
|
||||
- if @note.errors.any?
|
||||
#error_explanation
|
||||
%h2= "#{pluralize(@note.errors.count, "error")} prohibited this note from being saved:"
|
||||
%ul
|
||||
- @note.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
.field
|
||||
%p.label= f.label Note.human_attribute_name :contents
|
||||
= f.text_area :contents, cols: 70, rows: 10
|
||||
|
||||
.actions
|
||||
= f.submit t('save')
|
@ -0,0 +1,8 @@
|
||||
%h3
|
||||
= link_to t('.back'), moderations_path
|
||||
>>>
|
||||
=t '.title'
|
||||
|
||||
.box= render 'form'
|
||||
|
||||
.box= render file: '/events/show'
|
@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NotesControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@note = notes(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:notes)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
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 }
|
||||
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
|
||||
end
|
||||
end
|
@ -1,13 +1,13 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
event: one
|
||||
author: one
|
||||
contents: MyText
|
||||
date: 2014-01-05 23:34:46
|
||||
event_id:
|
||||
author_id:
|
||||
date: 2014-01-11 10:55:54
|
||||
|
||||
two:
|
||||
event: one
|
||||
author: one
|
||||
contents: MyText
|
||||
date: 2014-01-05 23:34:46
|
||||
event_id:
|
||||
author_id:
|
||||
date: 2014-01-11 10:55:54
|
||||
|
@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NotesHelperTest < ActionView::TestCase
|
||||
end
|
Loading…
Reference in new issue