added sections

This commit is contained in:
Edin Dazdarevic
2015-01-17 23:59:26 +01:00
parent e5809207a9
commit 6d1ac88a7f
8 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
class SectionsController < ApplicationController
active_scaffold :"section" do |conf|
end
end

View File

@@ -0,0 +1,2 @@
module SectionsHelper
end

View File

@@ -1,3 +1,4 @@
class Category < ActiveRecord::Base
has_many :sub_categories
belongs_to :section
end

3
app/models/section.rb Normal file
View File

@@ -0,0 +1,3 @@
class Section < ActiveRecord::Base
has_many :categories
end

View File

@@ -1,4 +1,5 @@
Rails.application.routes.draw do
resources :sections do as_routes end
resources :sub_categories do as_routes end
resources :categories do as_routes end
# The priority is based upon order of creation: first created -> highest priority.

View File

@@ -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: { name: @section.name }
end
assert_redirected_to section_path(assigns(:section))
end
test "should show section" do
get :show, id: @section
assert_response :success
end
test "should get edit" do
get :edit, id: @section
assert_response :success
end
test "should update section" do
patch :update, id: @section, section: { name: @section.name }
assert_redirected_to section_path(assigns(:section))
end
test "should destroy section" do
assert_difference('Section.count', -1) do
delete :destroy, id: @section
end
assert_redirected_to sections_path
end
end

7
test/fixtures/sections.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
two:
name: MyString

View File

@@ -0,0 +1,7 @@
require 'test_helper'
class SectionTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end