Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Subjects(data)-Pages-sections-scaffold

  • Loading branch information...
commit 916828feb6d16493c8c669558e5d989ed8e98514 1 parent f617e25
@first-developer authored
Showing with 841 additions and 106 deletions.
  1. +54 −12 app/controllers/pages_controller.rb
  2. +83 −0 app/controllers/sections_controller.rb
  3. +83 −0 app/controllers/subjects_controller.rb
  4. +2 −0  app/helpers/sections_helper.rb
  5. +2 −0  app/helpers/subjects_helper.rb
  6. +1 −1  app/models/page.rb
  7. +2 −0  app/models/section.rb
  8. +2 −0  app/models/subject.rb
  9. BIN  app/views/pages/.show.html.erb.swp
  10. +36 −10 app/views/pages/_form.html.erb
  11. +3 −5 app/views/pages/edit.html.erb
  12. +25 −13 app/views/pages/index.html.erb
  13. +2 −2 app/views/pages/new.html.erb
  14. +22 −8 app/views/pages/show.html.erb
  15. +37 −0 app/views/sections/_form.html.erb
  16. +6 −0 app/views/sections/edit.html.erb
  17. +31 −0 app/views/sections/index.html.erb
  18. +5 −0 app/views/sections/new.html.erb
  19. +30 −0 app/views/sections/show.html.erb
  20. +29 −0 app/views/subjects/_form.html.erb
  21. +6 −0 app/views/subjects/edit.html.erb
  22. +27 −0 app/views/subjects/index.html.erb
  23. +5 −0 app/views/subjects/new.html.erb
  24. +20 −0 app/views/subjects/show.html.erb
  25. +4 −0 config/routes.rb
  26. +0 −13 db/migrate/20110514124645_create_pages.rb
  27. +8 −0 db/migrate/20110520074200_drop_page_table.rb
  28. +17 −0 db/migrate/20110520075738_create_sections.rb
  29. +15 −0 db/migrate/20110520114216_create_subjects.rb
  30. +24 −3 db/schema.rb
  31. +4 −0 db/seeds.rb
  32. +56 −0 public/stylesheets/scaffold.css
  33. +12 −4 test/fixtures/pages.yml
  34. +15 −0 test/fixtures/sections.yml
  35. +16 −0 test/fixtures/subjects.yml
  36. +28 −33 test/functional/pages_controller_test.rb
  37. +49 −0 test/functional/sections_controller_test.rb
  38. +49 −0 test/functional/subjects_controller_test.rb
  39. +4 −0 test/unit/helpers/pages_helper_test.rb
  40. +4 −0 test/unit/helpers/sections_helper_test.rb
  41. +4 −0 test/unit/helpers/subjects_helper_test.rb
  42. +3 −2 test/unit/page_test.rb
  43. +8 −0 test/unit/section_test.rb
  44. +8 −0 test/unit/subject_test.rb
View
66 app/controllers/pages_controller.rb
@@ -1,41 +1,83 @@
class PagesController < ApplicationController
+ # GET /pages
+ # GET /pages.xml
def index
@pages = Page.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @pages }
+ end
end
+ # GET /pages/1
+ # GET /pages/1.xml
def show
@page = Page.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @page }
+ end
end
+ # GET /pages/new
+ # GET /pages/new.xml
def new
@page = Page.new
- end
- def create
- @page = Page.new(params[:page])
- if @page.save
- redirect_to @page, :notice => "Successfully created page."
- else
- render :action => 'new'
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @page }
end
end
+ # GET /pages/1/edit
def edit
@page = Page.find(params[:id])
end
+ # POST /pages
+ # POST /pages.xml
+ def create
+ @page = Page.new(params[:page])
+
+ respond_to do |format|
+ if @page.save
+ format.html { redirect_to(@page, :notice => 'Page was successfully created.') }
+ format.xml { render :xml => @page, :status => :created, :location => @page }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /pages/1
+ # PUT /pages/1.xml
def update
@page = Page.find(params[:id])
- if @page.update_attributes(params[:page])
- redirect_to @page, :notice => "Successfully updated page."
- else
- render :action => 'edit'
+
+ respond_to do |format|
+ if @page.update_attributes(params[:page])
+ format.html { redirect_to(@page, :notice => 'Page was successfully updated.') }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
+ end
end
end
+ # DELETE /pages/1
+ # DELETE /pages/1.xml
def destroy
@page = Page.find(params[:id])
@page.destroy
- redirect_to pages_url, :notice => "Successfully destroyed page."
+
+ respond_to do |format|
+ format.html { redirect_to(pages_url) }
+ format.xml { head :ok }
+ end
end
end
View
83 app/controllers/sections_controller.rb
@@ -0,0 +1,83 @@
+class SectionsController < ApplicationController
+ # GET /sections
+ # GET /sections.xml
+ def index
+ @sections = Section.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @sections }
+ end
+ end
+
+ # GET /sections/1
+ # GET /sections/1.xml
+ def show
+ @section = Section.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @section }
+ end
+ end
+
+ # GET /sections/new
+ # GET /sections/new.xml
+ def new
+ @section = Section.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @section }
+ end
+ end
+
+ # GET /sections/1/edit
+ def edit
+ @section = Section.find(params[:id])
+ end
+
+ # POST /sections
+ # POST /sections.xml
+ def create
+ @section = Section.new(params[:section])
+
+ respond_to do |format|
+ if @section.save
+ format.html { redirect_to(@section, :notice => 'Section was successfully created.') }
+ format.xml { render :xml => @section, :status => :created, :location => @section }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @section.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /sections/1
+ # PUT /sections/1.xml
+ def update
+ @section = Section.find(params[:id])
+
+ respond_to do |format|
+ if @section.update_attributes(params[:section])
+ format.html { redirect_to(@section, :notice => 'Section was successfully updated.') }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @section.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /sections/1
+ # DELETE /sections/1.xml
+ def destroy
+ @section = Section.find(params[:id])
+ @section.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(sections_url) }
+ format.xml { head :ok }
+ end
+ end
+end
View
83 app/controllers/subjects_controller.rb
@@ -0,0 +1,83 @@
+class SubjectsController < ApplicationController
+ # GET /subjects
+ # GET /subjects.xml
+ def index
+ @subjects = Subject.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @subjects }
+ end
+ end
+
+ # GET /subjects/1
+ # GET /subjects/1.xml
+ def show
+ @subject = Subject.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @subject }
+ end
+ end
+
+ # GET /subjects/new
+ # GET /subjects/new.xml
+ def new
+ @subject = Subject.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @subject }
+ end
+ end
+
+ # GET /subjects/1/edit
+ def edit
+ @subject = Subject.find(params[:id])
+ end
+
+ # POST /subjects
+ # POST /subjects.xml
+ def create
+ @subject = Subject.new(params[:subject])
+
+ respond_to do |format|
+ if @subject.save
+ format.html { redirect_to(@subject, :notice => 'Subject was successfully created.') }
+ format.xml { render :xml => @subject, :status => :created, :location => @subject }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @subject.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /subjects/1
+ # PUT /subjects/1.xml
+ def update
+ @subject = Subject.find(params[:id])
+
+ respond_to do |format|
+ if @subject.update_attributes(params[:subject])
+ format.html { redirect_to(@subject, :notice => 'Subject was successfully updated.') }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @subject.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /subjects/1
+ # DELETE /subjects/1.xml
+ def destroy
+ @subject = Subject.find(params[:id])
+ @subject.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(subjects_url) }
+ format.xml { head :ok }
+ end
+ end
+end
View
2  app/helpers/sections_helper.rb
@@ -0,0 +1,2 @@
+module SectionsHelper
+end
View
2  app/helpers/subjects_helper.rb
@@ -0,0 +1,2 @@
+module SubjectsHelper
+end
View
2  app/models/page.rb
@@ -1,3 +1,3 @@
class Page < ActiveRecord::Base
- attr_accessible :title, :body
+ belongs_to :subject
end
View
2  app/models/section.rb
@@ -0,0 +1,2 @@
+class Section < ActiveRecord::Base
+end
View
2  app/models/subject.rb
@@ -0,0 +1,2 @@
+class Subject < ActiveRecord::Base
+end
View
BIN  app/views/pages/.show.html.erb.swp
Binary file not shown
View
46 app/views/pages/_form.html.erb
@@ -1,11 +1,37 @@
-<%= form_for @page do |f| %>
- <p>
- <%= f.label :title %><br />
- <%= f.text_field :title %>
- </p>
- <p>
- <%= f.label :body %><br />
- <%= f.text_area :body %>
- </p>
- <p><%= f.submit %></p>
+<%= form_for(@page) do |f| %>
+ <% if @page.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@page.errors.count, "error") %> prohibited this page from being saved:</h2>
+
+ <ul>
+ <% @page.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
+ <%= f.label :permalink %><br />
+ <%= f.text_field :permalink %>
+ </div>
+ <div class="field">
+ <%= f.label :position %><br />
+ <%= f.text_field :position %>
+ </div>
+ <div class="field">
+ <%= f.label :visible %><br />
+ <%= f.check_box :visible %>
+ </div>
+ <div class="field">
+ <%= f.label :subject %><br />
+ <%= f.text_field :subject %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
<% end %>
View
8 app/views/pages/edit.html.erb
@@ -1,8 +1,6 @@
-<% "Edit Page" %>
+<h1>Editing page</h1>
<%= render 'form' %>
-<p>
- <%= link_to "Show", @page %> |
- <%= link_to "View All", pages_path %>
-</p>
+<%= link_to 'Show', @page %> |
+<%= link_to 'Back', pages_path %>
View
38 app/views/pages/index.html.erb
@@ -1,19 +1,31 @@
-<% "Pages" %>
+<h1>Listing pages</h1>
<table>
<tr>
- <th>Title</th>
- <th>Body</th>
+ <th>Name</th>
+ <th>Permalink</th>
+ <th>Position</th>
+ <th>Visible</th>
+ <th>Subject</th>
+ <th></th>
+ <th></th>
+ <th></th>
</tr>
- <% for page in @pages %>
- <tr>
- <td><%= page.title %></td>
- <td><%= page.body %></td>
- <td><%= link_to "Show", page %></td>
- <td><%= link_to "Edit", edit_page_path(page) %></td>
- <td><%= link_to "Destroy", page, :confirm => 'Are you sure?', :method => :delete %></td>
- </tr>
- <% end %>
+
+<% @pages.each do |page| %>
+ <tr>
+ <td><%= page.name %></td>
+ <td><%= page.permalink %></td>
+ <td><%= page.position %></td>
+ <td><%= page.visible %></td>
+ <td><%= page.subject %></td>
+ <td><%= link_to 'Show', page %></td>
+ <td><%= link_to 'Edit', edit_page_path(page) %></td>
+ <td><%= link_to 'Destroy', page, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
</table>
-<p><%= link_to "New Page", new_page_path %></p>
+<br />
+
+<%= link_to 'New Page', new_page_path %>
View
4 app/views/pages/new.html.erb
@@ -1,5 +1,5 @@
-<% "New Page" %>
+<h1>New page</h1>
<%= render 'form' %>
-<p><%= link_to "Back to List", pages_path %></p>
+<%= link_to 'Back', pages_path %>
View
30 app/views/pages/show.html.erb
@@ -1,16 +1,30 @@
-<% "Page" %>
+<p id="notice"><%= notice %></p>
<p>
- <strong>Title:</strong>
- <%= @page.title %>
+ <b>Name:</b>
+ <%= @page.name %>
</p>
+
<p>
- <strong>Body:</strong>
- <%= @page.body %>
+ <b>Permalink:</b>
+ <%= @page.permalink %>
</p>
<p>
- <%= link_to "Edit", edit_page_path(@page) %> |
- <%= link_to "Destroy", @page, :confirm => 'Are you sure?', :method => :delete %> |
- <%= link_to "View All", pages_path %>
+ <b>Position:</b>
+ <%= @page.position %>
</p>
+
+<p>
+ <b>Visible:</b>
+ <%= @page.visible %>
+</p>
+
+<p>
+ <b>Subject:</b>
+ <%= @page.subject %>
+</p>
+
+
+<%= link_to 'Edit', edit_page_path(@page) %> |
+<%= link_to 'Back', pages_path %>
View
37 app/views/sections/_form.html.erb
@@ -0,0 +1,37 @@
+<%= form_for(@section) do |f| %>
+ <% if @section.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@section.errors.count, "error") %> prohibited this section from being saved:</h2>
+
+ <ul>
+ <% @section.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
+ <%= f.label :position %><br />
+ <%= f.text_field :position %>
+ </div>
+ <div class="field">
+ <%= f.label :visible %><br />
+ <%= f.check_box :visible %>
+ </div>
+ <div class="field">
+ <%= f.label :content_type %><br />
+ <%= f.text_field :content_type %>
+ </div>
+ <div class="field">
+ <%= f.label :content %><br />
+ <%= f.text_area :content %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
View
6 app/views/sections/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing section</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @section %> |
+<%= link_to 'Back', sections_path %>
View
31 app/views/sections/index.html.erb
@@ -0,0 +1,31 @@
+<h1>Listing sections</h1>
+
+<table>
+ <tr>
+ <th>Name</th>
+ <th>Position</th>
+ <th>Visible</th>
+ <th>Content type</th>
+ <th>Content</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @sections.each do |section| %>
+ <tr>
+ <td><%= section.name %></td>
+ <td><%= section.position %></td>
+ <td><%= section.visible %></td>
+ <td><%= section.content_type %></td>
+ <td><%= section.content %></td>
+ <td><%= link_to 'Show', section %></td>
+ <td><%= link_to 'Edit', edit_section_path(section) %></td>
+ <td><%= link_to 'Destroy', section, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New Section', new_section_path %>
View
5 app/views/sections/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New section</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', sections_path %>
View
30 app/views/sections/show.html.erb
@@ -0,0 +1,30 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <b>Name:</b>
+ <%= @section.name %>
+</p>
+
+<p>
+ <b>Position:</b>
+ <%= @section.position %>
+</p>
+
+<p>
+ <b>Visible:</b>
+ <%= @section.visible %>
+</p>
+
+<p>
+ <b>Content type:</b>
+ <%= @section.content_type %>
+</p>
+
+<p>
+ <b>Content:</b>
+ <%= @section.content %>
+</p>
+
+
+<%= link_to 'Edit', edit_section_path(@section) %> |
+<%= link_to 'Back', sections_path %>
View
29 app/views/subjects/_form.html.erb
@@ -0,0 +1,29 @@
+<%= form_for(@subject) do |f| %>
+ <% if @subject.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@subject.errors.count, "error") %> prohibited this subject from being saved:</h2>
+
+ <ul>
+ <% @subject.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
+ <%= f.label :position %><br />
+ <%= f.text_field :position %>
+ </div>
+ <div class="field">
+ <%= f.label :visible %><br />
+ <%= f.check_box :visible %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
View
6 app/views/subjects/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing subject</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @subject %> |
+<%= link_to 'Back', subjects_path %>
View
27 app/views/subjects/index.html.erb
@@ -0,0 +1,27 @@
+<h1>Listing subjects</h1>
+
+<table>
+ <tr>
+ <th>Name</th>
+ <th>Position</th>
+ <th>Visible</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @subjects.each do |subject| %>
+ <tr>
+ <td><%= subject.name %></td>
+ <td><%= subject.position %></td>
+ <td><%= subject.visible %></td>
+ <td><%= link_to 'Show', subject %></td>
+ <td><%= link_to 'Edit', edit_subject_path(subject) %></td>
+ <td><%= link_to 'Destroy', subject, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New Subject', new_subject_path %>
View
5 app/views/subjects/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New subject</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', subjects_path %>
View
20 app/views/subjects/show.html.erb
@@ -0,0 +1,20 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <b>Name:</b>
+ <%= @subject.name %>
+</p>
+
+<p>
+ <b>Position:</b>
+ <%= @subject.position %>
+</p>
+
+<p>
+ <b>Visible:</b>
+ <%= @subject.visible %>
+</p>
+
+
+<%= link_to 'Edit', edit_subject_path(@subject) %> |
+<%= link_to 'Back', subjects_path %>
View
4 config/routes.rb
@@ -1,4 +1,8 @@
Manager::Application.routes.draw do
+ resources :sections
+
+ resources :subjects
+
resources :pages
# The priority is based upon order of creation:
View
13 db/migrate/20110514124645_create_pages.rb
@@ -1,13 +0,0 @@
-class CreatePages < ActiveRecord::Migration
- def self.up
- create_table :pages do |t|
- t.string :title
- t.text :body
- t.timestamps
- end
- end
-
- def self.down
- drop_table :pages
- end
-end
View
8 db/migrate/20110520074200_drop_page_table.rb
@@ -0,0 +1,8 @@
+class DropPageTable < ActiveRecord::Migration
+ def self.up
+ drop_table :pages
+ end
+
+ def self.down
+ end
+end
View
17 db/migrate/20110520075738_create_sections.rb
@@ -0,0 +1,17 @@
+class CreateSections < ActiveRecord::Migration
+ def self.up
+ create_table :sections do |t|
+ t.string :name
+ t.integer :position
+ t.boolean :visible
+ t.string :content_type
+ t.text :content
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :sections
+ end
+end
View
15 db/migrate/20110520114216_create_subjects.rb
@@ -0,0 +1,15 @@
+class CreateSubjects < ActiveRecord::Migration
+ def self.up
+ create_table :subjects do |t|
+ t.string :name
+ t.integer :position
+ t.boolean :visible
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :subjects
+ end
+end
View
27 db/schema.rb
@@ -10,11 +10,32 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110514124645) do
+ActiveRecord::Schema.define(:version => 20110520114216) do
create_table "pages", :force => true do |t|
- t.string "title"
- t.text "body"
+ t.string "name"
+ t.string "permalink"
+ t.integer "position"
+ t.boolean "visible"
+ t.integer "subject_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "sections", :force => true do |t|
+ t.string "name"
+ t.integer "position"
+ t.boolean "visible"
+ t.string "content_type"
+ t.text "content"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "subjects", :force => true do |t|
+ t.string "name"
+ t.integer "position"
+ t.boolean "visible"
t.datetime "created_at"
t.datetime "updated_at"
end
View
4 db/seeds.rb
@@ -5,3 +5,7 @@
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Daley', :city => cities.first)
+
+require 'active_record/fixtures'
+
+Fixtures.create_fixtures("#{Rails.root}/test/fixtures","subjects")
View
56 public/stylesheets/scaffold.css
@@ -0,0 +1,56 @@
+body { background-color: #fff; color: #333; }
+
+body, 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; }
+a:visited { color: #666; }
+a:hover { color: #fff; background-color:#000; }
+
+div.field, div.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;
+}
+
+#error_explanation 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;
+}
+
+#error_explanation ul li {
+ font-size: 12px;
+ list-style: square;
+}
View
16 test/fixtures/pages.yml
@@ -1,7 +1,15 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
one:
- title: MyString
- body: MyText
+ name: MyString
+ permalink: MyString
+ position: 1
+ visible: false
+ subject:
two:
- title: MyString
- body: MyText
+ name: MyString
+ permalink: MyString
+ position: 1
+ visible: false
+ subject:
View
15 test/fixtures/sections.yml
@@ -0,0 +1,15 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+one:
+ name: MyString
+ position: 1
+ visible: false
+ content_type: MyString
+ content: MyText
+
+two:
+ name: MyString
+ position: 1
+ visible: false
+ content_type: MyString
+ content: MyText
View
16 test/fixtures/subjects.yml
@@ -0,0 +1,16 @@
+s1:
+ name: Apprendre à manger souvent au McDo pour les nuls
+s2:
+ name: Apprendre à se souler pour les nuls
+s3:
+ name: Apprendre à voyager pour les nuls
+s4:
+ name: Apprendre à dessiner pour les nuls
+s5:
+ name: Apprendre à voler pour les nuls
+s6:
+ name: Apprendre à sourire pour les nuls
+s7:
+ name: Faut-il manger souvent au McDo
+
+
View
61 test/functional/pages_controller_test.rb
@@ -1,54 +1,49 @@
require 'test_helper'
class PagesControllerTest < ActionController::TestCase
- def test_index
- get :index
- assert_template 'index'
+ setup do
+ @page = pages(:one)
end
- def test_show
- get :show, :id => Page.first
- assert_template 'show'
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:pages)
end
- def test_new
+ test "should get new" do
get :new
- assert_template 'new'
+ assert_response :success
end
- def test_create_invalid
- Page.any_instance.stubs(:valid?).returns(false)
- post :create
- assert_template 'new'
- end
+ test "should create page" do
+ assert_difference('Page.count') do
+ post :create, :page => @page.attributes
+ end
- def test_create_valid
- Page.any_instance.stubs(:valid?).returns(true)
- post :create
- assert_redirected_to page_url(assigns(:page))
+ assert_redirected_to page_path(assigns(:page))
end
- def test_edit
- get :edit, :id => Page.first
- assert_template 'edit'
+ test "should show page" do
+ get :show, :id => @page.to_param
+ assert_response :success
end
- def test_update_invalid
- Page.any_instance.stubs(:valid?).returns(false)
- put :update, :id => Page.first
- assert_template 'edit'
+ test "should get edit" do
+ get :edit, :id => @page.to_param
+ assert_response :success
end
- def test_update_valid
- Page.any_instance.stubs(:valid?).returns(true)
- put :update, :id => Page.first
- assert_redirected_to page_url(assigns(:page))
+ test "should update page" do
+ put :update, :id => @page.to_param, :page => @page.attributes
+ assert_redirected_to page_path(assigns(:page))
end
- def test_destroy
- page = Page.first
- delete :destroy, :id => page
- assert_redirected_to pages_url
- assert !Page.exists?(page.id)
+ test "should destroy page" do
+ assert_difference('Page.count', -1) do
+ delete :destroy, :id => @page.to_param
+ end
+
+ assert_redirected_to pages_path
end
end
View
49 test/functional/sections_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class SectionsControllerTest < ActionController::TestCase
+ setup do
+ @section = sections(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:sections)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create section" do
+ assert_difference('Section.count') do
+ post :create, :section => @section.attributes
+ end
+
+ assert_redirected_to section_path(assigns(:section))
+ end
+
+ test "should show section" do
+ get :show, :id => @section.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, :id => @section.to_param
+ assert_response :success
+ end
+
+ test "should update section" do
+ put :update, :id => @section.to_param, :section => @section.attributes
+ assert_redirected_to section_path(assigns(:section))
+ end
+
+ test "should destroy section" do
+ assert_difference('Section.count', -1) do
+ delete :destroy, :id => @section.to_param
+ end
+
+ assert_redirected_to sections_path
+ end
+end
View
49 test/functional/subjects_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class SubjectsControllerTest < ActionController::TestCase
+ setup do
+ @subject = subjects(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:subjects)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create subject" do
+ assert_difference('Subject.count') do
+ post :create, :subject => @subject.attributes
+ end
+
+ assert_redirected_to subject_path(assigns(:subject))
+ end
+
+ test "should show subject" do
+ get :show, :id => @subject.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, :id => @subject.to_param
+ assert_response :success
+ end
+
+ test "should update subject" do
+ put :update, :id => @subject.to_param, :subject => @subject.attributes
+ assert_redirected_to subject_path(assigns(:subject))
+ end
+
+ test "should destroy subject" do
+ assert_difference('Subject.count', -1) do
+ delete :destroy, :id => @subject.to_param
+ end
+
+ assert_redirected_to subjects_path
+ end
+end
View
4 test/unit/helpers/pages_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class PagesHelperTest < ActionView::TestCase
+end
View
4 test/unit/helpers/sections_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class SectionsHelperTest < ActionView::TestCase
+end
View
4 test/unit/helpers/subjects_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class SubjectsHelperTest < ActionView::TestCase
+end
View
5 test/unit/page_test.rb
@@ -1,7 +1,8 @@
require 'test_helper'
class PageTest < ActiveSupport::TestCase
- def test_should_be_valid
- assert Page.new.valid?
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
end
end
View
8 test/unit/section_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class SectionTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
View
8 test/unit/subject_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class SubjectTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.