diff options
| -rw-r--r-- | app/controllers/events_controller.rb | 85 | ||||
| -rw-r--r-- | app/helpers/events_helper.rb | 2 | ||||
| -rw-r--r-- | app/models/event.rb | 2 | ||||
| -rw-r--r-- | app/views/events/edit.html.erb | 16 | ||||
| -rw-r--r-- | app/views/events/index.html.erb | 20 | ||||
| -rw-r--r-- | app/views/events/new.html.erb | 15 | ||||
| -rw-r--r-- | app/views/events/show.html.erb | 8 | ||||
| -rw-r--r-- | app/views/layouts/events.html.erb | 17 | ||||
| -rw-r--r-- | config/routes.rb | 4 | ||||
| -rw-r--r-- | db/migrate/20090310190600_create_events.rb | 13 | ||||
| -rw-r--r-- | public/stylesheets/scaffold.css | 54 | ||||
| -rw-r--r-- | test/fixtures/events.yml | 7 | ||||
| -rw-r--r-- | test/functional/events_controller_test.rb | 45 | ||||
| -rw-r--r-- | test/unit/event_test.rb | 77 | ||||
| -rw-r--r-- | test/unit/helpers/events_helper_test.rb | 4 |
15 files changed, 1 insertions, 368 deletions
diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb deleted file mode 100644 index 063b7a1..0000000 --- a/app/controllers/events_controller.rb +++ /dev/null | |||
| @@ -1,85 +0,0 @@ | |||
| 1 | class EventsController < ApplicationController | ||
| 2 | # GET /events | ||
| 3 | # GET /events.xml | ||
| 4 | def index | ||
| 5 | @events = Event.find(:all) | ||
| 6 | |||
| 7 | respond_to do |format| | ||
| 8 | format.html # index.html.erb | ||
| 9 | format.xml { render :xml => @events } | ||
| 10 | end | ||
| 11 | end | ||
| 12 | |||
| 13 | # GET /events/1 | ||
| 14 | # GET /events/1.xml | ||
| 15 | def show | ||
| 16 | @event = Event.find(params[:id]) | ||
| 17 | |||
| 18 | respond_to do |format| | ||
| 19 | format.html # show.html.erb | ||
| 20 | format.xml { render :xml => @event } | ||
| 21 | end | ||
| 22 | end | ||
| 23 | |||
| 24 | # GET /events/new | ||
| 25 | # GET /events/new.xml | ||
| 26 | def new | ||
| 27 | @event = Event.new | ||
| 28 | |||
| 29 | respond_to do |format| | ||
| 30 | format.html # new.html.erb | ||
| 31 | format.xml { render :xml => @event } | ||
| 32 | end | ||
| 33 | end | ||
| 34 | |||
| 35 | # GET /events/1/edit | ||
| 36 | def edit | ||
| 37 | @event = Event.find(params[:id]) | ||
| 38 | end | ||
| 39 | |||
| 40 | # POST /events | ||
| 41 | # POST /events.xml | ||
| 42 | def create | ||
| 43 | @event = Event.new(params[:event]) | ||
| 44 | |||
| 45 | respond_to do |format| | ||
| 46 | if @event.save | ||
| 47 | flash[:notice] = 'Event was successfully created.' | ||
| 48 | format.html { redirect_to(@event) } | ||
| 49 | format.xml { render :xml => @event, :status => :created, :location => @event } | ||
| 50 | else | ||
| 51 | format.html { render :action => "new" } | ||
| 52 | format.xml { render :xml => @event.errors, :status => :unprocessable_entity } | ||
| 53 | end | ||
| 54 | end | ||
| 55 | end | ||
| 56 | |||
| 57 | # PUT /events/1 | ||
| 58 | # PUT /events/1.xml | ||
| 59 | def update | ||
| 60 | @event = Event.find(params[:id]) | ||
| 61 | |||
| 62 | respond_to do |format| | ||
| 63 | if @event.update_attributes(params[:event]) | ||
| 64 | flash[:notice] = 'Event was successfully updated.' | ||
| 65 | format.html { redirect_to(@event) } | ||
| 66 | format.xml { head :ok } | ||
| 67 | else | ||
| 68 | format.html { render :action => "edit" } | ||
| 69 | format.xml { render :xml => @event.errors, :status => :unprocessable_entity } | ||
| 70 | end | ||
| 71 | end | ||
| 72 | end | ||
| 73 | |||
| 74 | # DELETE /events/1 | ||
| 75 | # DELETE /events/1.xml | ||
| 76 | def destroy | ||
| 77 | @event = Event.find(params[:id]) | ||
| 78 | @event.destroy | ||
| 79 | |||
| 80 | respond_to do |format| | ||
| 81 | format.html { redirect_to(events_url) } | ||
| 82 | format.xml { head :ok } | ||
| 83 | end | ||
| 84 | end | ||
| 85 | end | ||
diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb deleted file mode 100644 index 8a9a878..0000000 --- a/app/helpers/events_helper.rb +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | module EventsHelper | ||
| 2 | end | ||
diff --git a/app/models/event.rb b/app/models/event.rb deleted file mode 100644 index 3a829fd..0000000 --- a/app/models/event.rb +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | class Event < ActiveRecord::Base | ||
| 2 | end | ||
diff --git a/app/views/events/edit.html.erb b/app/views/events/edit.html.erb deleted file mode 100644 index 244f35f..0000000 --- a/app/views/events/edit.html.erb +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | <h1>Editing event</h1> | ||
| 2 | |||
| 3 | <% form_for(@event) do |f| %> | ||
| 4 | <%= f.error_messages %> | ||
| 5 | |||
| 6 | <p> | ||
| 7 | <%= f.label :serialized_event %><br /> | ||
| 8 | <%= f.text_area :serialized_event %> | ||
| 9 | </p> | ||
| 10 | <p> | ||
| 11 | <%= f.submit "Update" %> | ||
| 12 | </p> | ||
| 13 | <% end %> | ||
| 14 | |||
| 15 | <%= link_to 'Show', @event %> | | ||
| 16 | <%= link_to 'Back', events_path %> | ||
diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb deleted file mode 100644 index ad0ca8d..0000000 --- a/app/views/events/index.html.erb +++ /dev/null | |||
| @@ -1,20 +0,0 @@ | |||
| 1 | <h1>Listing events</h1> | ||
| 2 | |||
| 3 | <table> | ||
| 4 | <tr> | ||
| 5 | <th>Serialized event</th> | ||
| 6 | </tr> | ||
| 7 | |||
| 8 | <% for event in @events %> | ||
| 9 | <tr> | ||
| 10 | <td><%=h event.serialized_event %></td> | ||
| 11 | <td><%= link_to 'Show', event %></td> | ||
| 12 | <td><%= link_to 'Edit', edit_event_path(event) %></td> | ||
| 13 | <td><%= link_to 'Destroy', event, :confirm => 'Are you sure?', :method => :delete %></td> | ||
| 14 | </tr> | ||
| 15 | <% end %> | ||
| 16 | </table> | ||
| 17 | |||
| 18 | <br /> | ||
| 19 | |||
| 20 | <%= link_to 'New event', new_event_path %> | ||
diff --git a/app/views/events/new.html.erb b/app/views/events/new.html.erb deleted file mode 100644 index 44f4bb4..0000000 --- a/app/views/events/new.html.erb +++ /dev/null | |||
| @@ -1,15 +0,0 @@ | |||
| 1 | <h1>New event</h1> | ||
| 2 | |||
| 3 | <% form_for(@event) do |f| %> | ||
| 4 | <%= f.error_messages %> | ||
| 5 | |||
| 6 | <p> | ||
| 7 | <%= f.label :serialized_event %><br /> | ||
| 8 | <%= f.text_area :serialized_event %> | ||
| 9 | </p> | ||
| 10 | <p> | ||
| 11 | <%= f.submit "Create" %> | ||
| 12 | </p> | ||
| 13 | <% end %> | ||
| 14 | |||
| 15 | <%= link_to 'Back', events_path %> | ||
diff --git a/app/views/events/show.html.erb b/app/views/events/show.html.erb deleted file mode 100644 index ad9c582..0000000 --- a/app/views/events/show.html.erb +++ /dev/null | |||
| @@ -1,8 +0,0 @@ | |||
| 1 | <p> | ||
| 2 | <b>Serialized event:</b> | ||
| 3 | <%=h @event.serialized_event %> | ||
| 4 | </p> | ||
| 5 | |||
| 6 | |||
| 7 | <%= link_to 'Edit', edit_event_path(@event) %> | | ||
| 8 | <%= link_to 'Back', events_path %> | ||
diff --git a/app/views/layouts/events.html.erb b/app/views/layouts/events.html.erb deleted file mode 100644 index 6201c57..0000000 --- a/app/views/layouts/events.html.erb +++ /dev/null | |||
| @@ -1,17 +0,0 @@ | |||
| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
| 2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
| 3 | |||
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
| 5 | <head> | ||
| 6 | <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> | ||
| 7 | <title>Events: <%= controller.action_name %></title> | ||
| 8 | <%= stylesheet_link_tag 'scaffold' %> | ||
| 9 | </head> | ||
| 10 | <body> | ||
| 11 | |||
| 12 | <p style="color: green"><%= flash[:notice] %></p> | ||
| 13 | |||
| 14 | <%= yield %> | ||
| 15 | |||
| 16 | </body> | ||
| 17 | </html> | ||
diff --git a/config/routes.rb b/config/routes.rb index 33216b3..24735b5 100644 --- a/config/routes.rb +++ b/config/routes.rb | |||
| @@ -9,9 +9,7 @@ ActionController::Routing::Routes.draw do |map| | |||
| 9 | map.filter :locale | 9 | map.filter :locale |
| 10 | 10 | ||
| 11 | map.resources :pages | 11 | map.resources :pages |
| 12 | map.resources :nodes, :member => {:publish => :put, :unlock => :put} | 12 | map.resources :nodes, :member => {:publish => :put, :unlock => :put} |
| 13 | map.resources :events | ||
| 14 | |||
| 15 | map.logout '/logout', :controller => 'sessions', :action => 'destroy' | 13 | map.logout '/logout', :controller => 'sessions', :action => 'destroy' |
| 16 | map.login '/login', :controller => 'sessions', :action => 'new' | 14 | map.login '/login', :controller => 'sessions', :action => 'new' |
| 17 | map.resources :users | 15 | map.resources :users |
diff --git a/db/migrate/20090310190600_create_events.rb b/db/migrate/20090310190600_create_events.rb deleted file mode 100644 index da220d3..0000000 --- a/db/migrate/20090310190600_create_events.rb +++ /dev/null | |||
| @@ -1,13 +0,0 @@ | |||
| 1 | class CreateEvents < ActiveRecord::Migration | ||
| 2 | def self.up | ||
| 3 | create_table :events do |t| | ||
| 4 | t.text :serialized_event | ||
| 5 | |||
| 6 | t.timestamps | ||
| 7 | end | ||
| 8 | end | ||
| 9 | |||
| 10 | def self.down | ||
| 11 | drop_table :events | ||
| 12 | end | ||
| 13 | end | ||
diff --git a/public/stylesheets/scaffold.css b/public/stylesheets/scaffold.css deleted file mode 100644 index 093c209..0000000 --- a/public/stylesheets/scaffold.css +++ /dev/null | |||
| @@ -1,54 +0,0 @@ | |||
| 1 | body { background-color: #fff; color: #333; } | ||
| 2 | |||
| 3 | body, p, ol, ul, td { | ||
| 4 | font-family: verdana, arial, helvetica, sans-serif; | ||
| 5 | font-size: 13px; | ||
| 6 | line-height: 18px; | ||
| 7 | } | ||
| 8 | |||
| 9 | pre { | ||
| 10 | background-color: #eee; | ||
| 11 | padding: 10px; | ||
| 12 | font-size: 11px; | ||
| 13 | } | ||
| 14 | |||
| 15 | a { color: #000; } | ||
| 16 | a:visited { color: #666; } | ||
| 17 | a:hover { color: #fff; background-color:#000; } | ||
| 18 | |||
| 19 | .fieldWithErrors { | ||
| 20 | padding: 2px; | ||
| 21 | background-color: red; | ||
| 22 | display: table; | ||
| 23 | } | ||
| 24 | |||
| 25 | #errorExplanation { | ||
| 26 | width: 400px; | ||
| 27 | border: 2px solid red; | ||
| 28 | padding: 7px; | ||
| 29 | padding-bottom: 12px; | ||
| 30 | margin-bottom: 20px; | ||
| 31 | background-color: #f0f0f0; | ||
| 32 | } | ||
| 33 | |||
| 34 | #errorExplanation h2 { | ||
| 35 | text-align: left; | ||
| 36 | font-weight: bold; | ||
| 37 | padding: 5px 5px 5px 15px; | ||
| 38 | font-size: 12px; | ||
| 39 | margin: -7px; | ||
| 40 | background-color: #c00; | ||
| 41 | color: #fff; | ||
| 42 | } | ||
| 43 | |||
| 44 | #errorExplanation p { | ||
| 45 | color: #333; | ||
| 46 | margin-bottom: 0; | ||
| 47 | padding: 5px; | ||
| 48 | } | ||
| 49 | |||
| 50 | #errorExplanation ul li { | ||
| 51 | font-size: 12px; | ||
| 52 | list-style: square; | ||
| 53 | } | ||
| 54 | |||
diff --git a/test/fixtures/events.yml b/test/fixtures/events.yml deleted file mode 100644 index 6d43f1d..0000000 --- a/test/fixtures/events.yml +++ /dev/null | |||
| @@ -1,7 +0,0 @@ | |||
| 1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
| 2 | |||
| 3 | one: | ||
| 4 | serialized_event: MyText | ||
| 5 | |||
| 6 | two: | ||
| 7 | serialized_event: MyText | ||
diff --git a/test/functional/events_controller_test.rb b/test/functional/events_controller_test.rb deleted file mode 100644 index 24a6f94..0000000 --- a/test/functional/events_controller_test.rb +++ /dev/null | |||
| @@ -1,45 +0,0 @@ | |||
| 1 | require 'test_helper' | ||
| 2 | |||
| 3 | class EventsControllerTest < ActionController::TestCase | ||
| 4 | test "should get index" do | ||
| 5 | get :index | ||
| 6 | assert_response :success | ||
| 7 | assert_not_nil assigns(:events) | ||
| 8 | end | ||
| 9 | |||
| 10 | test "should get new" do | ||
| 11 | get :new | ||
| 12 | assert_response :success | ||
| 13 | end | ||
| 14 | |||
| 15 | test "should create event" do | ||
| 16 | assert_difference('Event.count') do | ||
| 17 | post :create, :event => { } | ||
| 18 | end | ||
| 19 | |||
| 20 | assert_redirected_to event_path(assigns(:event)) | ||
| 21 | end | ||
| 22 | |||
| 23 | test "should show event" do | ||
| 24 | get :show, :id => events(:one).id | ||
| 25 | assert_response :success | ||
| 26 | end | ||
| 27 | |||
| 28 | test "should get edit" do | ||
| 29 | get :edit, :id => events(:one).id | ||
| 30 | assert_response :success | ||
| 31 | end | ||
| 32 | |||
| 33 | test "should update event" do | ||
| 34 | put :update, :id => events(:one).id, :event => { } | ||
| 35 | assert_redirected_to event_path(assigns(:event)) | ||
| 36 | end | ||
| 37 | |||
| 38 | test "should destroy event" do | ||
| 39 | assert_difference('Event.count', -1) do | ||
| 40 | delete :destroy, :id => events(:one).id | ||
| 41 | end | ||
| 42 | |||
| 43 | assert_redirected_to events_path | ||
| 44 | end | ||
| 45 | end | ||
diff --git a/test/unit/event_test.rb b/test/unit/event_test.rb deleted file mode 100644 index c8ee335..0000000 --- a/test/unit/event_test.rb +++ /dev/null | |||
| @@ -1,77 +0,0 @@ | |||
| 1 | require 'test_helper' | ||
| 2 | |||
| 3 | class EventTest < ActiveSupport::TestCase | ||
| 4 | |||
| 5 | def setup | ||
| 6 | @cal = <<-EOT | ||
| 7 | BEGIN:VCALENDAR | ||
| 8 | VERSION:2.0 | ||
| 9 | PRODID:-//Ensemble Independent//vPim 0.658//EN | ||
| 10 | CALSCALE:Gregorian | ||
| 11 | BEGIN:VEVENT | ||
| 12 | SUMMARY:Chaosradio | ||
| 13 | DTSTART:20080505T220000 | ||
| 14 | LOCATION:FM 102,60 MHz | ||
| 15 | URL:http://www.fritz.de/frequenzen | ||
| 16 | RRULE:FREQ=MONTHLY;BYMONTH=1,2,3,4,5,6,7,8,9,10,11;BYDAY=-1WE;UNTIL=20091105T220000 | ||
| 17 | CREATED:20021020T220000 | ||
| 18 | DURATION:PT3H | ||
| 19 | END:VEVENT | ||
| 20 | END:VCALENDAR | ||
| 21 | EOT | ||
| 22 | |||
| 23 | @first_child = Node.find(2) | ||
| 24 | end | ||
| 25 | |||
| 26 | test 'saving serialized event' do | ||
| 27 | assert event = Event.create!( :serialized_event => @cal ) | ||
| 28 | end | ||
| 29 | |||
| 30 | test 'parsing calendar data' do | ||
| 31 | event = Event.create!( :serialized_event => @cal ) | ||
| 32 | assert calendar = ChaosCalendar.new | ||
| 33 | assert calendar.push( event.serialized_event, @first_child.id ) | ||
| 34 | assert_equal 1, calendar.calendar.length | ||
| 35 | assert_equal "Chaosradio", calendar.calendar.to_a.first.first.summary | ||
| 36 | end | ||
| 37 | |||
| 38 | test 'checking occurrences logic' do | ||
| 39 | event = Event.create!( :serialized_event => @cal ) | ||
| 40 | calendar = ChaosCalendar.new | ||
| 41 | calendar.push( event.serialized_event, @first_child.id ) | ||
| 42 | |||
| 43 | all_occurrences = calendar.occurrences( "2009-03-22".to_datetime, "2010-01-10".to_datetime ) | ||
| 44 | assert_equal 8, all_occurrences.length | ||
| 45 | |||
| 46 | assert_equal "2009-03-25".to_date, all_occurrences.first.dtstart.to_date | ||
| 47 | assert_equal "2009-10-28".to_date, all_occurrences.last.dtstart.to_date | ||
| 48 | end | ||
| 49 | |||
| 50 | end | ||
| 51 | |||
| 52 | __END__ | ||
| 53 | |||
| 54 | opt_days = 7 | ||
| 55 | |||
| 56 | calendar = ChaosCalendar.new | ||
| 57 | |||
| 58 | |||
| 59 | calendar.push( cal, 25 ) | ||
| 60 | t0 = Time.today | ||
| 61 | t1 = t0 + opt_days.days | ||
| 62 | |||
| 63 | all_occurrences = calendar.occurrences( t0, t1 ) | ||
| 64 | |||
| 65 | all_occurrences.each do |o| | ||
| 66 | e = o.event | ||
| 67 | puts o.dtstart | ||
| 68 | puts "#{e.summary}:" | ||
| 69 | |||
| 70 | puts " description=#{e.description}" if e.description | ||
| 71 | puts " comment=#{e.comments.first}" if e.comments | ||
| 72 | puts " location=#{e.location}" if e.location | ||
| 73 | puts " status=#{e.status}" if e.status | ||
| 74 | puts " dtstart=#{e.dtstart}" if e.dtstart | ||
| 75 | puts " duration=#{Vpim::Duration.new(e.duration).to_s}" if e.duration | ||
| 76 | end | ||
| 77 | |||
diff --git a/test/unit/helpers/events_helper_test.rb b/test/unit/helpers/events_helper_test.rb deleted file mode 100644 index 2e7567e..0000000 --- a/test/unit/helpers/events_helper_test.rb +++ /dev/null | |||
| @@ -1,4 +0,0 @@ | |||
| 1 | require 'test_helper' | ||
| 2 | |||
| 3 | class EventsHelperTest < ActionView::TestCase | ||
| 4 | end | ||
