Testing tests

This commit is contained in:
Godwin
2014-03-23 13:31:08 -06:00
parent 55d47180e0
commit fda5646974
17 changed files with 199 additions and 199 deletions
+7 -1
View File
@@ -125,6 +125,12 @@ class ConferencesController < ApplicationController
set_conference
end
def workshops
set_conference
@workshops = Workshop.where(:conference_id => @conference.id)
render 'workshops/index'
end
# DELETE /conferences/1
def destroy
@conference.destroy
@@ -134,7 +140,7 @@ class ConferencesController < ApplicationController
private
# Use callbacks to share common setup or constraints between actions.
def set_conference
@conference = Conference.find_by(slug: params[:slug] || params[:conference_slug])
@conference = Conference.find_by(slug: params[:conference_slug] || params[:slug])
set_conference_registration
end
+57 -46
View File
@@ -1,58 +1,69 @@
class WorkshopsController < ApplicationController
before_action :set_workshop, only: [:show, :edit, :update, :destroy]
before_action :set_workshop, only: [:show, :edit, :update, :destroy]
# GET /workshops
def index
@workshops = Workshop.all
end
# GET /workshops
def index
set_conference
@workshops = Workshop.where(['conference_id = ?', @conference.id])
end
# GET /workshops/1
def show
end
# GET /workshops/1
def show
set_workshop
set_conference
end
# GET /workshops/new
def new
@workshop = Workshop.new
end
# GET /workshops/new
def new
set_conference
@workshop = Workshop.new
end
# GET /workshops/1/edit
def edit
end
# GET /workshops/1/edit
def edit
set_conference
end
# POST /workshops
def create
@workshop = Workshop.new(workshop_params)
# POST /workshops
def create
set_conference
@workshop = Workshop.new(workshop_params)
if @workshop.save
redirect_to @workshop, notice: 'Workshop was successfully created.'
else
render action: 'new'
end
end
if @workshop.save
redirect_to conference_workshop_path(@conference, @workshop), notice: 'Workshop was successfully created.'
else
render action: 'new'
end
end
# PATCH/PUT /workshops/1
def update
if @workshop.update(workshop_params)
redirect_to @workshop, notice: 'Workshop was successfully updated.'
else
render action: 'edit'
end
end
# PATCH/PUT /workshops/1
def update
set_conference
if @workshop.update(workshop_params)
redirect_to conference_workshop_path(@conference, @workshop), notice: 'Workshop was successfully updated.'
else
render action: 'edit'
end
end
# DELETE /workshops/1
def destroy
@workshop.destroy
redirect_to workshops_url, notice: 'Workshop was successfully destroyed.'
end
# DELETE /workshops/1
def destroy
@workshop.destroy
redirect_to workshops_url, notice: 'Workshop was successfully destroyed.'
end
private
# Use callbacks to share common setup or constraints between actions.
def set_workshop
@workshop = Workshop.find(params[:id])
end
private
# Use callbacks to share common setup or constraints between actions.
def set_workshop
@workshop = Workshop.find_by(slug: params[:workshop_slug] || params[:slug])
end
# Only allow a trusted parameter "white list" through.
def workshop_params
params.require(:workshop).permit(:title, :slug, :info, :conference_id, :workshop_stream_id, :workshop_presentation_style, :min_facilitators, :location_id, :start_time, :end_time)
end
def set_conference
@conference = Conference.find_by(slug: params[:conference_slug] || params[:slug])
end
# Only allow a trusted parameter "white list" through.
def workshop_params
params.require(:workshop).permit(:title, :slug, :info, :conference_id, :workshop_stream_id, :workshop_presentation_style, :min_facilitators, :location_id, :start_time, :end_time)
end
end
+15 -1
View File
@@ -406,7 +406,18 @@ module ApplicationHelper
if params[:action] == tab.to_s
c << 'current'
end
tab_list += link_to tab, link || object, :class => c
link_html = ''
if tab.is_a?(Hash)
func = tab.keys[0]
val = tab[func]
args = val ? (val.is_a?(Array) ? (val.collect { |v| object[v] } ) : [object[val]] ) : nil
link_html = link_to func.to_s.gsub(/_path$/, ''), args ? self.send(func, args) : self.send(func), :class => c
else
#x
link_html = link_to tab, link || object, :class => c
end
tab_list += link_html
end
('<nav class="row centered">
<div class="tabs">' +
@@ -425,6 +436,9 @@ module ApplicationHelper
when 'conferences'
object = @conference
tabs = ConferencesHelper::TABS
when 'workshops'
object = [@conference, @workshop]
tabs = WorkshopsHelper::TABS
end
if object && tabs
+2
View File
@@ -1,2 +1,4 @@
module WorkshopsHelper
TABS = [{:conference_path => 0}, {:conference_workshop_path => nil}, {:edit_conference_workshop_path => nil}]#, :hosts]
#SUB_TABS = [:registration, :registration_form, :registration_register, :registration_stats]
end
+2
View File
@@ -10,6 +10,8 @@ class Conference < ActiveRecord::Base
has_many :conference_registration_form_fields, :order => 'position ASC', :dependent => :destroy#, :class_name => '::ConferenceRegistrationFormField'
has_many :registration_form_fields, :through => :conference_registration_form_fields
has_many :workshops
accepts_nested_attributes_for :conference_host_organizations, :reject_if => proc {|u| u[:organization_id].blank?}, :allow_destroy => true
def to_param
+5
View File
@@ -1,2 +1,7 @@
class Workshop < ActiveRecord::Base
belongs_to :conference
def to_param
slug
end
end
+23 -40
View File
@@ -1,40 +1,23 @@
= form_for @workshop do |f|
- if @workshop.errors.any?
#error_explanation
%h2= "#{pluralize(@workshop.errors.count, "error")} prohibited this workshop from being saved:"
%ul
- @workshop.errors.full_messages.each do |msg|
%li= msg
.field
= f.label :title
= f.text_field :title
.field
= f.label :slug
= f.text_field :slug
.field
= f.label :info
= f.text_area :info
.field
= f.label :conference_id
= f.number_field :conference_id
.field
= f.label :workshop_stream_id
= f.number_field :workshop_stream_id
.field
= f.label :workshop_presentation_style
= f.number_field :workshop_presentation_style
.field
= f.label :min_facilitators
= f.number_field :min_facilitators
.field
= f.label :location_id
= f.number_field :location_id
.field
= f.label :start_time
= f.datetime_select :start_time
.field
= f.label :end_time
= f.datetime_select :end_time
.actions
= f.submit 'Save'
= form_for @workshop, url: conference_workshops_path(@conference, @workshop) do |f|
.columns
- if @workshop.errors.any?
#error_explanation
%h2= "#{pluralize(@workshop.errors.count, "error")} prohibited this workshop from being saved:"
%ul
- @workshop.errors.full_messages.each do |msg|
%li= msg
= field f, :title, :text_field
= field f, :slug, :text_field
.columns.medium-4
%h2=_'workshop.form.help.title', :t
=_'workshop.form.help', :p
.columns.medium-8
= field f, :info, :text_area
= field f, :workshop_stream_id, :number_field
= field f, :workshop_presentation_style, :number_field
=# field f, :min_facilitators, :number_field
=# field f, :location_id, :number_field
=# field f, :start_time, :datetime_select
=# field f, :end_time, :datetime_select
.columns
= actions :save
+4 -5
View File
@@ -1,7 +1,6 @@
%h1 Editing workshop
- page_style :form
= render 'form'
= tabs!
= link_to 'Show', @workshop
\|
= link_to 'Back', workshops_path
.row
= render 'form'
+3 -5
View File
@@ -14,7 +14,6 @@
%th End time
%th
%th
%th
- @workshops.each do |workshop|
%tr
@@ -28,10 +27,9 @@
%td= workshop.location_id
%td= workshop.start_time
%td= workshop.end_time
%td= link_to 'Show', workshop
%td= link_to 'Edit', edit_workshop_path(workshop)
%td= link_to 'Destroy', workshop, :method => :delete, :data => { :confirm => 'Are you sure?' }
%td= link_to 'Show', conference_workshop_path(@conference, workshop)
%td= link_to 'Edit', edit_conference_workshop_path(@conference, workshop)
%br
= link_to 'New Workshop', new_workshop_path
= link_to 'New Workshop', new_conference_workshop_path
+4 -3
View File
@@ -1,5 +1,6 @@
%h1 New workshop
- page_style :form
= render 'form'
= tabs!
= link_to 'Back', workshops_path
.row
= render 'form'
+27 -33
View File
@@ -1,36 +1,30 @@
%p#notice= notice
%p
%b Title:
= @workshop.title
%p
%b Slug:
= @workshop.slug
%p
%b Info:
= @workshop.info
%p
%b Conference:
= @workshop.conference_id
%p
%b Workshop stream:
= @workshop.workshop_stream_id
%p
%b Workshop presentation style:
= @workshop.workshop_presentation_style
%p
%b Min facilitators:
= @workshop.min_facilitators
%p
%b Location:
= @workshop.location_id
%p
%b Start time:
= @workshop.start_time
%p
%b End time:
= @workshop.end_time
.row
.columns.medium-12
%h1= @workshop.title
= link_to 'Edit', edit_workshop_path(@workshop)
\|
= link_to 'Back', workshops_path
= tabs!
.row
.columns.medium-4
%p
%b Workshop stream:
= @workshop.workshop_stream_id
%p
%b Workshop presentation style:
= @workshop.workshop_presentation_style
%p
%b Min facilitators:
= @workshop.min_facilitators
%p
%b Location:
= @workshop.location_id
%p
%b Start time:
= @workshop.start_time
%p
%b End time:
= @workshop.end_time
.columns.medium-8
=p @workshop, :info