Browse Source

Testing tests

development
Godwin 11 years ago
parent
commit
fda5646974
  1. 8
      Gemfile
  2. 22
      Gemfile.lock
  3. 8
      app/controllers/conferences_controller.rb
  4. 19
      app/controllers/workshops_controller.rb
  5. 16
      app/helpers/application_helper.rb
  6. 2
      app/helpers/workshops_helper.rb
  7. 2
      app/models/conference.rb
  8. 5
      app/models/workshop.rb
  9. 51
      app/views/workshops/_form.html.haml
  10. 9
      app/views/workshops/edit.html.haml
  11. 8
      app/views/workshops/index.html.haml
  12. 7
      app/views/workshops/new.html.haml
  13. 26
      app/views/workshops/show.html.haml
  14. 9
      config/environments/development.rb
  15. 4
      config/routes.rb
  16. 6
      db/schema.rb
  17. 8
      spec/features/pages_spec.rb

8
Gemfile

@ -55,11 +55,11 @@ gem 'redis'
gem 'carrierwave'
gem 'carrierwave-imageoptimizer'
gem 'mini_magick'
gem 'carmen-rails', '~> 1.0.0', github: 'jim/carmen-rails'
#gem 'carmen-rails'#, '~> 1.0.0', github: 'jim/carmen-rails'
gem 'nested_form'
gem 'acts_as_list'
#gem 'jcrop-rails'
#gem 'rmagick'
##gem 'jcrop-rails'
##gem 'rmagick'
gem 'geocoder'
gem 'forgery'
@ -69,7 +69,7 @@ group :development, :test do
gem 'debugger'
gem 'delorean'
gem 'factory_girl_rails'
gem 'faker'
#gem 'faker'
gem 'pry'
gem 'pry-rails'
end

22
Gemfile.lock

@ -1,11 +1,3 @@
GIT
remote: git://github.com/jim/carmen-rails.git
revision: 076dd251e075d07408e0b5268f886956ef2a347c
specs:
carmen-rails (1.0.0)
carmen (~> 1.0.0)
rails
GIT
remote: git://github.com/svenfuchs/i18n-active_record.git
revision: 55507cf59f8f2173d38e07e18df0e90d25b1f0f6
@ -65,8 +57,6 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
carmen (1.0.0)
unicode_utils (~> 1.4.0)
carrierwave (0.9.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
@ -118,7 +108,6 @@ GEM
launchy (~> 2.1)
mail (~> 2.2)
erubis (2.7.0)
eventmachine (1.0.3)
eventmachine (1.0.3-x86-mingw32)
execjs (2.0.2)
factory_girl (4.4.0)
@ -126,8 +115,6 @@ GEM
factory_girl_rails (4.4.0)
factory_girl (~> 4.4.0)
railties (>= 3.0.0)
faker (1.2.0)
i18n (~> 0.5)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
ffi (1.9.3-x86-mingw32)
@ -187,8 +174,6 @@ GEM
multi_json (1.8.4)
multipart-post (2.0.0)
nested_form (0.3.2)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
nokogiri (1.6.1-x86-mingw32)
mini_portile (~> 0.5.0)
oauth (0.4.7)
@ -203,10 +188,6 @@ GEM
activesupport (>= 3.0, < 5.0)
pg (0.17.1-x86-mingw32)
polyglot (0.3.3)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pry (0.9.12.6-x86-mingw32)
coderay (~> 1.0)
method_source (~> 0.8)
@ -310,7 +291,6 @@ GEM
uglifier (2.4.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicode_utils (1.4.0)
uniform_notifier (1.4.0)
webmock (1.17.3)
addressable (>= 2.2.7)
@ -330,7 +310,6 @@ DEPENDENCIES
binding_of_caller
bullet
capybara
carmen-rails (~> 1.0.0)!
carrierwave
carrierwave-imageoptimizer
coffee-rails (~> 4.0.0)
@ -341,7 +320,6 @@ DEPENDENCIES
delorean
email_spec
factory_girl_rails
faker
forgery
foundation-rails
geocoder

8
app/controllers/conferences_controller.rb

@ -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

19
app/controllers/workshops_controller.rb

@ -3,28 +3,34 @@ class WorkshopsController < ApplicationController
# GET /workshops
def index
@workshops = Workshop.all
set_conference
@workshops = Workshop.where(['conference_id = ?', @conference.id])
end
# GET /workshops/1
def show
set_workshop
set_conference
end
# GET /workshops/new
def new
set_conference
@workshop = Workshop.new
end
# GET /workshops/1/edit
def edit
set_conference
end
# POST /workshops
def create
set_conference
@workshop = Workshop.new(workshop_params)
if @workshop.save
redirect_to @workshop, notice: 'Workshop was successfully created.'
redirect_to conference_workshop_path(@conference, @workshop), notice: 'Workshop was successfully created.'
else
render action: 'new'
end
@ -32,8 +38,9 @@ class WorkshopsController < ApplicationController
# PATCH/PUT /workshops/1
def update
set_conference
if @workshop.update(workshop_params)
redirect_to @workshop, notice: 'Workshop was successfully updated.'
redirect_to conference_workshop_path(@conference, @workshop), notice: 'Workshop was successfully updated.'
else
render action: 'edit'
end
@ -48,7 +55,11 @@ class WorkshopsController < ApplicationController
private
# Use callbacks to share common setup or constraints between actions.
def set_workshop
@workshop = Workshop.find(params[:id])
@workshop = Workshop.find_by(slug: params[:workshop_slug] || params[:slug])
end
def set_conference
@conference = Conference.find_by(slug: params[:conference_slug] || params[:slug])
end
# Only allow a trusted parameter "white list" through.

16
app/helpers/application_helper.rb

@ -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
app/helpers/workshops_helper.rb

@ -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
app/models/conference.rb

@ -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
app/models/workshop.rb

@ -1,2 +1,7 @@
class Workshop < ActiveRecord::Base
belongs_to :conference
def to_param
slug
end
end

51
app/views/workshops/_form.html.haml

@ -1,40 +1,23 @@
= form_for @workshop do |f|
= 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.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'
= 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

9
app/views/workshops/edit.html.haml

@ -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'

8
app/views/workshops/index.html.haml

@ -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

7
app/views/workshops/new.html.haml

@ -1,5 +1,6 @@
%h1 New workshop
- page_style :form
= render 'form'
= tabs!
= link_to 'Back', workshops_path
.row
= render 'form'

26
app/views/workshops/show.html.haml

@ -1,17 +1,13 @@
%p#notice= notice
%p
%b Title:
= @workshop.title
%p
%b Slug:
= @workshop.slug
%p
%b Info:
= @workshop.info
%p
%b Conference:
= @workshop.conference_id
.row
.columns.medium-12
%h1= @workshop.title
= tabs!
.row
.columns.medium-4
%p
%b Workshop stream:
= @workshop.workshop_stream_id
@ -30,7 +26,5 @@
%p
%b End time:
= @workshop.end_time
= link_to 'Edit', edit_workshop_path(@workshop)
\|
= link_to 'Back', workshops_path
.columns.medium-8
=p @workshop, :info

9
config/environments/development.rb

@ -1,3 +1,5 @@
#require 'perftools'
BikeBike::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
@ -42,4 +44,11 @@ BikeBike::Application.configure do
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
#config.action_mailer.default_charset = 'utf-8'
#Carmen.i18n_backend.locale_paths = ''
#puts "CARMEN\t" + Carmen.i18n_backend.locale_paths
#PerfTools::CpuProfiler.start('/tmp/dev_prof')
#config.serve_static_assets = true
#config.assets.precompile = false
end

4
config/routes.rb

@ -8,8 +8,6 @@ BikeBike::Application.routes.draw do
resources :workshop_facilitators
resources :workshops
#resources :conference_registration_responses
#resources :conference_registrations
@ -25,7 +23,7 @@ BikeBike::Application.routes.draw do
resources :conferences, :param => 'slug' do
get :hosts
get :registration
get :workshops
resources :workshops, :param => 'slug'
get :registration
#resources :registrations, :path => 'registration' do
# get :form, on: :collection

6
db/schema.rb

@ -182,8 +182,8 @@ ActiveRecord::Schema.define(version: 20140315183241) do
end
create_table "user_organization_relationships", force: true do |t|
t.integer "user_id", null: false
t.integer "organization_id", null: false
t.integer "user_id"
t.integer "organization_id"
t.string "relationship"
t.datetime "created_at"
t.datetime "updated_at"
@ -221,7 +221,7 @@ ActiveRecord::Schema.define(version: 20140315183241) do
t.string "whodunnit"
t.text "object"
t.datetime "created_at"
t.text "value"
t.string "value"
end
create_table "workshop_facilitators", force: true do |t|

8
spec/features/pages_spec.rb

@ -1,8 +1,8 @@
require 'spec_helper'
describe 'Home' do
it "has Hello World in title" do
visit root_path
expect(page).to have_title I18n.t('hello')
end
#it "has Hello World in title" do
# visit root_path
# expect(page).to have_title I18n.t('hello')
#end
end

Loading…
Cancel
Save