forked from bofh/fetsite
Introducing Lecturers
This commit is contained in:
3
app/assets/javascripts/lecturers.js.coffee
Normal file
3
app/assets/javascripts/lecturers.js.coffee
Normal file
@@ -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://jashkenas.github.com/coffee-script/
|
||||||
3
app/assets/stylesheets/lecturers.css.scss
Normal file
3
app/assets/stylesheets/lecturers.css.scss
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
// Place all the styles related to the lecturers controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||||
83
app/controllers/lecturers_controller.rb
Normal file
83
app/controllers/lecturers_controller.rb
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
class LecturersController < ApplicationController
|
||||||
|
# GET /lecturers
|
||||||
|
# GET /lecturers.json
|
||||||
|
def index
|
||||||
|
@lecturers = Lecturer.all
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.json { render json: @lecturers }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /lecturers/1
|
||||||
|
# GET /lecturers/1.json
|
||||||
|
def show
|
||||||
|
@lecturer = Lecturer.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # show.html.erb
|
||||||
|
format.json { render json: @lecturer }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /lecturers/new
|
||||||
|
# GET /lecturers/new.json
|
||||||
|
def new
|
||||||
|
@lecturer = Lecturer.new
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # new.html.erb
|
||||||
|
format.json { render json: @lecturer }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /lecturers/1/edit
|
||||||
|
def edit
|
||||||
|
@lecturer = Lecturer.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /lecturers
|
||||||
|
# POST /lecturers.json
|
||||||
|
def create
|
||||||
|
@lecturer = Lecturer.new(params[:lecturer])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @lecturer.save
|
||||||
|
format.html { redirect_to @lecturer, notice: 'Lecturer was successfully created.' }
|
||||||
|
format.json { render json: @lecturer, status: :created, location: @lecturer }
|
||||||
|
else
|
||||||
|
format.html { render action: "new" }
|
||||||
|
format.json { render json: @lecturer.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PUT /lecturers/1
|
||||||
|
# PUT /lecturers/1.json
|
||||||
|
def update
|
||||||
|
@lecturer = Lecturer.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @lecturer.update_attributes(params[:lecturer])
|
||||||
|
format.html { redirect_to @lecturer, notice: 'Lecturer was successfully updated.' }
|
||||||
|
format.json { head :no_content }
|
||||||
|
else
|
||||||
|
format.html { render action: "edit" }
|
||||||
|
format.json { render json: @lecturer.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /lecturers/1
|
||||||
|
# DELETE /lecturers/1.json
|
||||||
|
def destroy
|
||||||
|
@lecturer = Lecturer.find(params[:id])
|
||||||
|
@lecturer.destroy
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to lecturers_url }
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
2
app/helpers/lecturers_helper.rb
Normal file
2
app/helpers/lecturers_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
module LecturersHelper
|
||||||
|
end
|
||||||
4
app/models/lecturer.rb
Normal file
4
app/models/lecturer.rb
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
class Lecturer < ActiveRecord::Base
|
||||||
|
attr_accessible :email, :name, :oid, :picture, :lva_ids
|
||||||
|
has_and_belongs_to_many :lvas
|
||||||
|
end
|
||||||
@@ -13,17 +13,17 @@
|
|||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
# modul_id :integer
|
# modul_id :integer
|
||||||
# semester_id :integer
|
# semester_id :integer
|
||||||
#
|
#
|
||||||
|
|
||||||
class Lva < ActiveRecord::Base
|
class Lva < ActiveRecord::Base
|
||||||
ERLAUBTE_TYPEN = ['VO', 'UE', 'VU', 'LU', 'SE', 'andere'];
|
ERLAUBTE_TYPEN = ['VO', 'UE', 'VU', 'LU', 'SE', 'andere'];
|
||||||
has_paper_trail # Versionsverfolgung
|
has_paper_trail # Versionsverfolgung
|
||||||
attr_accessible :desc, :ects, :lvanr, :name, :stunden, :modul_ids, :semester_ids, :pruefungsinformation, :lernaufwand, :typ
|
attr_accessible :desc, :ects, :lvanr, :name, :stunden, :modul_ids, :semester_ids, :pruefungsinformation, :lernaufwand, :typ, :lecturer_ids
|
||||||
has_and_belongs_to_many :modul # Gehört zu einem Modul
|
has_and_belongs_to_many :modul # Gehört zu einem Modul
|
||||||
has_and_belongs_to_many :semester
|
has_and_belongs_to_many :semester
|
||||||
#Gehört zu einem Semester( derzeit nicht implementiert)
|
#Gehört zu einem Semester( derzeit nicht implementiert)
|
||||||
has_many :beispiele , :class_name => "Beispiel"
|
has_many :beispiele , :class_name => "Beispiel"
|
||||||
|
has_and_belongs_to_many :lecturers
|
||||||
translates :desc, :fallbacks_for_empty_translations => true
|
translates :desc, :fallbacks_for_empty_translations => true
|
||||||
|
|
||||||
validates :lvanr,:format=>{ :with => /^[0-9][0-9][0-9]\.[0-9][0-9][0-9]$/}, :presence=>true, :uniqueness=>true # , :uniqueness=>true # LVA-Nummer muss das Format 000.000 besitzen (uniqueness?) oder 000 für nicht
|
validates :lvanr,:format=>{ :with => /^[0-9][0-9][0-9]\.[0-9][0-9][0-9]$/}, :presence=>true, :uniqueness=>true # , :uniqueness=>true # LVA-Nummer muss das Format 000.000 besitzen (uniqueness?) oder 000 für nicht
|
||||||
|
|||||||
13
app/views/lecturers/_form.html.erb
Normal file
13
app/views/lecturers/_form.html.erb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<%= semantic_form_for @lecturer do |f| %>
|
||||||
|
<%= f.inputs do %>
|
||||||
|
<%= f.input :name %>
|
||||||
|
<%= f.input :email %>
|
||||||
|
<%= f.input :oid %>
|
||||||
|
<%= f.input :picture %>
|
||||||
|
<%= f.input :lvas %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= f.actions do %>
|
||||||
|
<%= f.action :submit, :as => :input %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
6
app/views/lecturers/edit.html.erb
Normal file
6
app/views/lecturers/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<h1>Editing lecturer</h1>
|
||||||
|
|
||||||
|
<%= render 'form' %>
|
||||||
|
|
||||||
|
<%= link_to 'Show', @lecturer %> |
|
||||||
|
<%= link_to 'Back', lecturers_path %>
|
||||||
29
app/views/lecturers/index.html.erb
Normal file
29
app/views/lecturers/index.html.erb
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<h1>Listing lecturers</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Oid</th>
|
||||||
|
<th>Picture</th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% @lecturers.each do |lecturer| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= lecturer.name %></td>
|
||||||
|
<td><%= lecturer.email %></td>
|
||||||
|
<td><%= lecturer.oid %></td>
|
||||||
|
<td><%= lecturer.picture %></td>
|
||||||
|
<td><%= link_to 'Show', lecturer %></td>
|
||||||
|
<td><%= link_to 'Edit', edit_lecturer_path(lecturer) %></td>
|
||||||
|
<td><%= link_to 'Destroy', lecturer, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<%= link_to 'New Lecturer', new_lecturer_path %>
|
||||||
5
app/views/lecturers/new.html.erb
Normal file
5
app/views/lecturers/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<h1>New lecturer</h1>
|
||||||
|
|
||||||
|
<%= render 'form' %>
|
||||||
|
|
||||||
|
<%= link_to 'Back', lecturers_path %>
|
||||||
25
app/views/lecturers/show.html.erb
Normal file
25
app/views/lecturers/show.html.erb
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<p id="notice"><%= notice %></p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<b>Name:</b>
|
||||||
|
<%= @lecturer.name %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<b>Email:</b>
|
||||||
|
<%= @lecturer.email %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<b>Oid:</b>
|
||||||
|
<%= @lecturer.oid %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<b>Picture:</b>
|
||||||
|
<%= @lecturer.picture %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<%= link_to 'Edit', edit_lecturer_path(@lecturer) %> |
|
||||||
|
<%= link_to 'Back', lecturers_path %>
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
<div class="lva-semester">
|
<div class="lva-semester">
|
||||||
<b><%= link_to lva.name, lva_path(lva)%></b><br>
|
<%=lva.lvanr.to_s %> <b><%= link_to lva.name, lva_path(lva)%></b> <%= lva.ects %> ECTS / <%= lva.stunden %> Std<br>
|
||||||
|
<!-- <div class="hidden-phone">
|
||||||
Module: /<% lva.modul.each do |m| %> <%= link_to m.name + ' / ', modul_path(m) unless m.modulgruppen.map{|x| x.studium}.index(@studium).nil? && !@studium.nil? %><% end %>
|
Module: /<% lva.modul.each do |m| %> <%= link_to m.name + ' / ', modul_path(m) unless m.modulgruppen.map{|x| x.studium}.index(@studium).nil? && !@studium.nil? %><% end %>
|
||||||
<br>
|
<br>
|
||||||
<%="LVa-Nr " + lva.lvanr.to_s %>
|
|
||||||
<%= lva.ects %> ECTS / <%= lva.stunden %> Std <% " / " + lva.beispiele.count.to_s + " Beispiele"%> <br>
|
<% " / " + lva.beispiele.count.to_s + " Beispiele"%> </div>-->
|
||||||
<%= link_to "Edit", edit_lva_path(lva) %> | <%= link_to "Beispiel hinzufügen", new_beispiel_path(:lva_id=>lva.id) %>
|
|
||||||
</div class="lva-semester">
|
</div class="lva-semester">
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
Fetsite::Application.routes.draw do
|
Fetsite::Application.routes.draw do
|
||||||
|
|
||||||
|
resources :lecturers
|
||||||
|
|
||||||
|
|
||||||
devise_for :users
|
devise_for :users
|
||||||
resources :home, :only=>[:index]
|
resources :home, :only=>[:index]
|
||||||
#get 'home',:controller=>home,:action=>:index,:as=>"home_index"
|
#get 'home',:controller=>home,:action=>:index,:as=>"home_index"
|
||||||
@@ -34,6 +37,7 @@
|
|||||||
|
|
||||||
end
|
end
|
||||||
get 'verwalten/studien', :controller=>:studien, :action=>:verwalten, :as=>'studien_verwalten'
|
get 'verwalten/studien', :controller=>:studien, :action=>:verwalten, :as=>'studien_verwalten'
|
||||||
|
resources :lecturers
|
||||||
resources :semesters
|
resources :semesters
|
||||||
resources :moduls
|
resources :moduls
|
||||||
resources :lvas
|
resources :lvas
|
||||||
|
|||||||
12
db/migrate/20130819132647_create_lecturers.rb
Normal file
12
db/migrate/20130819132647_create_lecturers.rb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
class CreateLecturers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :lecturers do |t|
|
||||||
|
t.string :name
|
||||||
|
t.string :email
|
||||||
|
t.integer :oid
|
||||||
|
t.string :picture
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
13
db/migrate/20130819133111_create_lecturers_lvas.rb
Normal file
13
db/migrate/20130819133111_create_lecturers_lvas.rb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
class CreateLecturersLvas < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :lecturers_lvas, :id=> false do |t|
|
||||||
|
t.integer :lecturer_id
|
||||||
|
t.integer :lva_id
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
160
spec/controllers/lecturers_controller_spec.rb
Normal file
160
spec/controllers/lecturers_controller_spec.rb
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||||
|
# It demonstrates how one might use RSpec to specify the controller code that
|
||||||
|
# was generated by Rails when you ran the scaffold generator.
|
||||||
|
#
|
||||||
|
# It assumes that the implementation code is generated by the rails scaffold
|
||||||
|
# generator. If you are using any extension libraries to generate different
|
||||||
|
# controller code, this generated spec may or may not pass.
|
||||||
|
#
|
||||||
|
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||||
|
# of tools you can use to make these specs even more expressive, but we're
|
||||||
|
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||||
|
#
|
||||||
|
# Compared to earlier versions of this generator, there is very limited use of
|
||||||
|
# stubs and message expectations in this spec. Stubs are only used when there
|
||||||
|
# is no simpler way to get a handle on the object needed for the example.
|
||||||
|
# Message expectations are only used when there is no simpler way to specify
|
||||||
|
# that an instance is receiving a specific message.
|
||||||
|
|
||||||
|
describe LecturersController do
|
||||||
|
|
||||||
|
# This should return the minimal set of attributes required to create a valid
|
||||||
|
# Lecturer. As you add validations to Lecturer, be sure to
|
||||||
|
# adjust the attributes here as well.
|
||||||
|
let(:valid_attributes) { { "name" => "MyString" } }
|
||||||
|
|
||||||
|
# This should return the minimal set of values that should be in the session
|
||||||
|
# in order to pass any filters (e.g. authentication) defined in
|
||||||
|
# LecturersController. Be sure to keep this updated too.
|
||||||
|
let(:valid_session) { {} }
|
||||||
|
|
||||||
|
describe "GET index" do
|
||||||
|
it "assigns all lecturers as @lecturers" do
|
||||||
|
lecturer = Lecturer.create! valid_attributes
|
||||||
|
get :index, {}, valid_session
|
||||||
|
assigns(:lecturers).should eq([lecturer])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "GET show" do
|
||||||
|
it "assigns the requested lecturer as @lecturer" do
|
||||||
|
lecturer = Lecturer.create! valid_attributes
|
||||||
|
get :show, {:id => lecturer.to_param}, valid_session
|
||||||
|
assigns(:lecturer).should eq(lecturer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "GET new" do
|
||||||
|
it "assigns a new lecturer as @lecturer" do
|
||||||
|
get :new, {}, valid_session
|
||||||
|
assigns(:lecturer).should be_a_new(Lecturer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "GET edit" do
|
||||||
|
it "assigns the requested lecturer as @lecturer" do
|
||||||
|
lecturer = Lecturer.create! valid_attributes
|
||||||
|
get :edit, {:id => lecturer.to_param}, valid_session
|
||||||
|
assigns(:lecturer).should eq(lecturer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "POST create" do
|
||||||
|
describe "with valid params" do
|
||||||
|
it "creates a new Lecturer" do
|
||||||
|
expect {
|
||||||
|
post :create, {:lecturer => valid_attributes}, valid_session
|
||||||
|
}.to change(Lecturer, :count).by(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "assigns a newly created lecturer as @lecturer" do
|
||||||
|
post :create, {:lecturer => valid_attributes}, valid_session
|
||||||
|
assigns(:lecturer).should be_a(Lecturer)
|
||||||
|
assigns(:lecturer).should be_persisted
|
||||||
|
end
|
||||||
|
|
||||||
|
it "redirects to the created lecturer" do
|
||||||
|
post :create, {:lecturer => valid_attributes}, valid_session
|
||||||
|
response.should redirect_to(Lecturer.last)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "with invalid params" do
|
||||||
|
it "assigns a newly created but unsaved lecturer as @lecturer" do
|
||||||
|
# Trigger the behavior that occurs when invalid params are submitted
|
||||||
|
Lecturer.any_instance.stub(:save).and_return(false)
|
||||||
|
post :create, {:lecturer => { "name" => "invalid value" }}, valid_session
|
||||||
|
assigns(:lecturer).should be_a_new(Lecturer)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "re-renders the 'new' template" do
|
||||||
|
# Trigger the behavior that occurs when invalid params are submitted
|
||||||
|
Lecturer.any_instance.stub(:save).and_return(false)
|
||||||
|
post :create, {:lecturer => { "name" => "invalid value" }}, valid_session
|
||||||
|
response.should render_template("new")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "PUT update" do
|
||||||
|
describe "with valid params" do
|
||||||
|
it "updates the requested lecturer" do
|
||||||
|
lecturer = Lecturer.create! valid_attributes
|
||||||
|
# Assuming there are no other lecturers in the database, this
|
||||||
|
# specifies that the Lecturer created on the previous line
|
||||||
|
# receives the :update_attributes message with whatever params are
|
||||||
|
# submitted in the request.
|
||||||
|
Lecturer.any_instance.should_receive(:update_attributes).with({ "name" => "MyString" })
|
||||||
|
put :update, {:id => lecturer.to_param, :lecturer => { "name" => "MyString" }}, valid_session
|
||||||
|
end
|
||||||
|
|
||||||
|
it "assigns the requested lecturer as @lecturer" do
|
||||||
|
lecturer = Lecturer.create! valid_attributes
|
||||||
|
put :update, {:id => lecturer.to_param, :lecturer => valid_attributes}, valid_session
|
||||||
|
assigns(:lecturer).should eq(lecturer)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "redirects to the lecturer" do
|
||||||
|
lecturer = Lecturer.create! valid_attributes
|
||||||
|
put :update, {:id => lecturer.to_param, :lecturer => valid_attributes}, valid_session
|
||||||
|
response.should redirect_to(lecturer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "with invalid params" do
|
||||||
|
it "assigns the lecturer as @lecturer" do
|
||||||
|
lecturer = Lecturer.create! valid_attributes
|
||||||
|
# Trigger the behavior that occurs when invalid params are submitted
|
||||||
|
Lecturer.any_instance.stub(:save).and_return(false)
|
||||||
|
put :update, {:id => lecturer.to_param, :lecturer => { "name" => "invalid value" }}, valid_session
|
||||||
|
assigns(:lecturer).should eq(lecturer)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "re-renders the 'edit' template" do
|
||||||
|
lecturer = Lecturer.create! valid_attributes
|
||||||
|
# Trigger the behavior that occurs when invalid params are submitted
|
||||||
|
Lecturer.any_instance.stub(:save).and_return(false)
|
||||||
|
put :update, {:id => lecturer.to_param, :lecturer => { "name" => "invalid value" }}, valid_session
|
||||||
|
response.should render_template("edit")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "DELETE destroy" do
|
||||||
|
it "destroys the requested lecturer" do
|
||||||
|
lecturer = Lecturer.create! valid_attributes
|
||||||
|
expect {
|
||||||
|
delete :destroy, {:id => lecturer.to_param}, valid_session
|
||||||
|
}.to change(Lecturer, :count).by(-1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "redirects to the lecturers list" do
|
||||||
|
lecturer = Lecturer.create! valid_attributes
|
||||||
|
delete :destroy, {:id => lecturer.to_param}, valid_session
|
||||||
|
response.should redirect_to(lecturers_url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
10
spec/factories/lecturers.rb
Normal file
10
spec/factories/lecturers.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||||
|
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :lecturer do
|
||||||
|
name "MyString"
|
||||||
|
email "MyString"
|
||||||
|
oid 1
|
||||||
|
picture "MyString"
|
||||||
|
end
|
||||||
|
end
|
||||||
15
spec/helpers/lecturers_helper_spec.rb
Normal file
15
spec/helpers/lecturers_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
# Specs in this file have access to a helper object that includes
|
||||||
|
# the LecturersHelper. For example:
|
||||||
|
#
|
||||||
|
# describe LecturersHelper do
|
||||||
|
# describe "string concat" do
|
||||||
|
# it "concats two strings with spaces" do
|
||||||
|
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
describe LecturersHelper do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
5
spec/models/lecturer_spec.rb
Normal file
5
spec/models/lecturer_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Lecturer do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
11
spec/requests/lecturers_spec.rb
Normal file
11
spec/requests/lecturers_spec.rb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe "Lecturers" do
|
||||||
|
describe "GET /lecturers" do
|
||||||
|
it "works! (now write some real specs)" do
|
||||||
|
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
|
||||||
|
get lecturers_path
|
||||||
|
response.status.should be(200)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
35
spec/routing/lecturers_routing_spec.rb
Normal file
35
spec/routing/lecturers_routing_spec.rb
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
require "spec_helper"
|
||||||
|
|
||||||
|
describe LecturersController do
|
||||||
|
describe "routing" do
|
||||||
|
|
||||||
|
it "routes to #index" do
|
||||||
|
get("/lecturers").should route_to("lecturers#index")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #new" do
|
||||||
|
get("/lecturers/new").should route_to("lecturers#new")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #show" do
|
||||||
|
get("/lecturers/1").should route_to("lecturers#show", :id => "1")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #edit" do
|
||||||
|
get("/lecturers/1/edit").should route_to("lecturers#edit", :id => "1")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #create" do
|
||||||
|
post("/lecturers").should route_to("lecturers#create")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #update" do
|
||||||
|
put("/lecturers/1").should route_to("lecturers#update", :id => "1")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #destroy" do
|
||||||
|
delete("/lecturers/1").should route_to("lecturers#destroy", :id => "1")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
24
spec/views/lecturers/edit.html.erb_spec.rb
Normal file
24
spec/views/lecturers/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe "lecturers/edit" do
|
||||||
|
before(:each) do
|
||||||
|
@lecturer = assign(:lecturer, stub_model(Lecturer,
|
||||||
|
:name => "MyString",
|
||||||
|
:email => "MyString",
|
||||||
|
:oid => 1,
|
||||||
|
:picture => "MyString"
|
||||||
|
))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "renders the edit lecturer form" do
|
||||||
|
render
|
||||||
|
|
||||||
|
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||||
|
assert_select "form[action=?][method=?]", lecturer_path(@lecturer), "post" do
|
||||||
|
assert_select "input#lecturer_name[name=?]", "lecturer[name]"
|
||||||
|
assert_select "input#lecturer_email[name=?]", "lecturer[email]"
|
||||||
|
assert_select "input#lecturer_oid[name=?]", "lecturer[oid]"
|
||||||
|
assert_select "input#lecturer_picture[name=?]", "lecturer[picture]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
29
spec/views/lecturers/index.html.erb_spec.rb
Normal file
29
spec/views/lecturers/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe "lecturers/index" do
|
||||||
|
before(:each) do
|
||||||
|
assign(:lecturers, [
|
||||||
|
stub_model(Lecturer,
|
||||||
|
:name => "Name",
|
||||||
|
:email => "Email",
|
||||||
|
:oid => 1,
|
||||||
|
:picture => "Picture"
|
||||||
|
),
|
||||||
|
stub_model(Lecturer,
|
||||||
|
:name => "Name",
|
||||||
|
:email => "Email",
|
||||||
|
:oid => 1,
|
||||||
|
:picture => "Picture"
|
||||||
|
)
|
||||||
|
])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "renders a list of lecturers" do
|
||||||
|
render
|
||||||
|
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||||
|
assert_select "tr>td", :text => "Name".to_s, :count => 2
|
||||||
|
assert_select "tr>td", :text => "Email".to_s, :count => 2
|
||||||
|
assert_select "tr>td", :text => 1.to_s, :count => 2
|
||||||
|
assert_select "tr>td", :text => "Picture".to_s, :count => 2
|
||||||
|
end
|
||||||
|
end
|
||||||
24
spec/views/lecturers/new.html.erb_spec.rb
Normal file
24
spec/views/lecturers/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe "lecturers/new" do
|
||||||
|
before(:each) do
|
||||||
|
assign(:lecturer, stub_model(Lecturer,
|
||||||
|
:name => "MyString",
|
||||||
|
:email => "MyString",
|
||||||
|
:oid => 1,
|
||||||
|
:picture => "MyString"
|
||||||
|
).as_new_record)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "renders new lecturer form" do
|
||||||
|
render
|
||||||
|
|
||||||
|
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||||
|
assert_select "form[action=?][method=?]", lecturers_path, "post" do
|
||||||
|
assert_select "input#lecturer_name[name=?]", "lecturer[name]"
|
||||||
|
assert_select "input#lecturer_email[name=?]", "lecturer[email]"
|
||||||
|
assert_select "input#lecturer_oid[name=?]", "lecturer[oid]"
|
||||||
|
assert_select "input#lecturer_picture[name=?]", "lecturer[picture]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
21
spec/views/lecturers/show.html.erb_spec.rb
Normal file
21
spec/views/lecturers/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe "lecturers/show" do
|
||||||
|
before(:each) do
|
||||||
|
@lecturer = assign(:lecturer, stub_model(Lecturer,
|
||||||
|
:name => "Name",
|
||||||
|
:email => "Email",
|
||||||
|
:oid => 1,
|
||||||
|
:picture => "Picture"
|
||||||
|
))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "renders attributes in <p>" do
|
||||||
|
render
|
||||||
|
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||||
|
rendered.should match(/Name/)
|
||||||
|
rendered.should match(/Email/)
|
||||||
|
rendered.should match(/1/)
|
||||||
|
rendered.should match(/Picture/)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user