Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

make tests pass, cleanup routes #9

Merged
merged 3 commits into from

2 participants

@thommahoney

Delete tests of un-used controller actions
Delete views for un-used controller actions
Cleanup gitignored things
Readme notes about test running
make valid fixtures

jacobo added some commits
@jacobo jacobo make tests pass, cleanup routes
Delete tests of un-used controller actions
Delete views for un-used controller actions
Cleanup gitignored things
Readme notes about test running
make valid fixtures
f8a5680
@jacobo jacobo add pg gem a4505bf
@jacobo jacobo ci script for ensemble 29a2017
@thommahoney

tested in JRuby and Ruby. Everything looks good. Merging.

@thommahoney thommahoney merged commit dd12364 into master
@slack slack deleted the fix_tests branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 8, 2011
  1. @jacobo

    make tests pass, cleanup routes

    jacobo authored
    Delete tests of un-used controller actions
    Delete views for un-used controller actions
    Cleanup gitignored things
    Readme notes about test running
    make valid fixtures
  2. @jacobo

    add pg gem

    jacobo authored
  3. @jacobo

    ci script for ensemble

    jacobo authored
This page is out of date. Refresh to see the latest.
View
1  Gemfile
@@ -7,6 +7,7 @@ gem 'jquery-rails', '1.0.14'
platform :ruby do
gem 'mysql2', '~> 0.2.7'
+ gem 'pg'
gem 'sqlite3'
gem 'unicorn'
end
View
2  Gemfile.lock
@@ -51,6 +51,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.16)
mysql2 (0.2.13)
+ pg (0.11.0)
polyglot (0.3.2)
rack (1.2.4)
rack-mount (0.6.14)
@@ -103,6 +104,7 @@ DEPENDENCIES
jquery-rails (= 1.0.14)
jruby-openssl
mysql2 (~> 0.2.7)
+ pg
rails (= 3.0.9)
simple_form (= 1.5.1)
sqlite3
View
10 README.md
@@ -2,4 +2,12 @@
Simple GTD app for task tracking.
-Supports all Rubies and many stacks (passenger, unicorn, trinidad/jruby).
+Supports all Rubies and many stacks (passenger, unicorn, trinidad/jruby).
+
+# To run individual tests: (for example)
+
+bundle exec ruby -Itest test/functional/lists_controller_test.rb
+
+# To run specific tests: (for example)
+
+bundle exec ruby -Itest test/functional/lists_controller_test.rb --name test_should_create_list
View
4 app/controllers/lists_controller.rb
@@ -7,7 +7,7 @@ def create
else
flash[:alert] = "There was an error creating your list."
end
- redirect_to(tasks_url(:list => @list.id))
+ redirect_to(list_tasks_url(@list))
end
def destroy
@@ -15,7 +15,7 @@ def destroy
@list.destroy
respond_to do |format|
- format.html { redirect_to(tasks_url) }
+ format.html { redirect_to(root_url) }
end
end
end
View
12 app/controllers/tasks_controller.rb
@@ -14,22 +14,24 @@ def index
def create
- @task = Task.new(params[:task])
+ @list = List.find(params[:list_id])
+ @task = @list.tasks.new(params[:task])
if @task.save
flash[:notice] = "Your task was created."
else
flash[:alert] = "There was an error creating your task."
end
- redirect_to(tasks_url(:list => params[:task][:list_id]))
+ redirect_to(list_tasks_url(@list))
end
def update
- @task = Task.find(params[:id])
+ @list = List.find(params[:list_id])
+ @task = @list.tasks.find(params[:id])
respond_to do |format|
if @task.update_attributes(params[:task])
- format.html { redirect_to( tasks_url(:list => @task.list.id), :notice => 'Task was successfully updated.') }
+ format.html { redirect_to( list_tasks_url(@list), :notice => 'Task was successfully updated.') }
else
format.html { render :action => "edit" }
end
@@ -42,7 +44,7 @@ def destroy
@task.destroy
respond_to do |format|
- format.html { redirect_to(tasks_url(:list => @task.list_id)) }
+ format.html { redirect_to(list_tasks_url(@list)) }
end
end
View
6 app/views/lists/edit.html.erb
@@ -1,6 +0,0 @@
-<h1>Editing list</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Show', @list %> |
-<%= link_to 'Back', lists_path %>
View
23 app/views/lists/index.html.erb
@@ -1,23 +0,0 @@
-<h1>Listing lists</h1>
-
-<table>
- <tr>
- <th>Name</th>
- <th></th>
- <th></th>
- <th></th>
- </tr>
-
-<% @lists.each do |list| %>
- <tr>
- <td><%= list.name %></td>
- <td><%= link_to 'Show', list %></td>
- <td><%= link_to 'Edit', edit_list_path(list) %></td>
- <td></td>
- </tr>
-<% end %>
-</table>
-
-<br />
-
-<%= link_to 'New List', new_list_path %>
View
10 app/views/lists/show.html.erb
@@ -1,10 +0,0 @@
-<p id="notice"><%= notice %></p>
-
-<p>
- <b>Name:</b>
- <%= @list.name %>
-</p>
-
-
-<%= link_to 'Edit', edit_list_path(@list) %> |
-<%= link_to 'Back', lists_path %>
View
6 app/views/tasks/edit.html.erb
@@ -1,6 +0,0 @@
-<h1>Editing task</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Show', @task %> |
-<%= link_to 'Back', tasks_path %>
View
12 app/views/tasks/index.html.erb
@@ -19,7 +19,7 @@
<div id='tabs-<%= @count %>' class="tab">
<div class="new-task">
- <%= simple_form_for(@task) do |f| %>
+ <%= simple_form_for(@task, :url => list_tasks_url(list)) do |f| %>
<%= f.input :done , :as => :hidden, :input_html => {:value => false }%>
<%= f.input :list_id , :as => :hidden, :input_html => {:value => list.id }%>
@@ -40,14 +40,14 @@
<% list.tasks.each do |task| %>
<% unless task.done %>
- <%= simple_form_for(task) do |f| %>
+ <%= simple_form_for(task, :url => list_task_url(list, task)) do |f| %>
<li>
<%= f.input :done , :input_html => { :class => 'box' } , :label => false %>
<%= f.button :submit , :class => 'hidden' %>
<%= auto_link( h(task.name) ) %>
<p class="delete-task">
- <%= link_to 'X', task, :confirm => 'Are you sure?', :method => :delete %>
+ <%= link_to 'X', list_task_url(list, task), :confirm => 'Are you sure?', :method => :delete %>
</p>
</li>
@@ -63,7 +63,7 @@
<li class="finished">
<%= auto_link( h(task.name) ) %>
<p class="delete-task">
- <%= link_to 'X', task, :confirm => 'Are you sure?', :method => :delete %>
+ <%= link_to 'X', list_task_url(list, task), :confirm => 'Are you sure?', :method => :delete %>
</p>
</li>
<% end %>
@@ -88,7 +88,7 @@
</div>
-<% if listid = params[:list] %>
+<% if listid = params[:list_id] %>
<% prevlist = List.find listid %>
<% tabindex = @lists.index(prevlist) %>
<% end %>
@@ -101,7 +101,7 @@
$(function() {
var opts = {};
- <% if params[:list] %>
+ <% if params[:list_id] %>
opts.selected = <%= tabindex %>
<% end %>
$( "#tabs" ).tabs(opts);
View
5 config/routes.rb
@@ -1,7 +1,8 @@
Listr::Application.routes.draw do
- resources :lists
- resources :tasks
+ resources :lists, :only => [:create, :destroy] do
+ resources :tasks, :except => [:new, :edit, :show]
+ end
# The priority is based upon order of creation:
# first created -> highest priority.
View
0  db/test.sqlite3
No changes.
View
0  log/test.log
No changes.
View
44 script/ci
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+set -x
+set -e
+export LANG=en_US.UTF-8
+
+db_host=$DB_HOST
+db_user=$USER
+db_pass=$DB_PASS
+db_name=ensemble_ci_$$
+internal_key="/home/$USER/.ssh/internal"
+
+db_create_command="createdb -U postgres -h localhost -O $db_user $db_name"
+db_drop_command="dropdb -U postgres -h localhost $db_name"
+db_remote_command="ssh -F /dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i $internal_key root@$db_host"
+
+if [[ $db_host == "localhost" ]]; then
+ sudo -u postgres $db_create_command
+ trap "echo 'database cleanup'; sudo -u postgres ${db_drop_command}" EXIT
+else
+ $db_remote_command $db_create_command
+ trap "echo 'database cleanup'; ${db_remote_command} ${db_drop_command}" EXIT
+fi
+
+test -d config && {
+ cat > config/database.yml <<EOF
+test:
+ adapter: postgresql
+ user: $db_user
+ host: $db_host
+ database: $db_name
+ password: $db_pass
+EOF
+ }
+
+source use_ruby.sh
+use_ruby 1.9.2
+
+test -f Gemfile
+gem install bundler --no-rdoc --no-ri
+bundle
+
+bundle exec rake db:migrate
+time bundle exec rake --trace
+
View
4 test/fixtures/lists.yml
@@ -1,7 +1,7 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
- name: MyString
+ name: ListOne
two:
- name: MyString
+ name: ListTwo
View
6 test/fixtures/tasks.yml
@@ -1,9 +1,11 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
- name: MyString
+ name: TaskOne
done: false
+ list: one
two:
- name: MyString
+ name: TaskTwo
done: false
+ list: one
View
32 test/functional/lists_controller_test.rb
@@ -5,38 +5,12 @@ class ListsControllerTest < ActionController::TestCase
@list = lists(:one)
end
- test "should get index" do
- get :index
- assert_response :success
- assert_not_nil assigns(:lists)
- end
-
- test "should get new" do
- get :new
- assert_response :success
- end
-
test "should create list" do
assert_difference('List.count') do
- post :create, :list => @list.attributes
+ post :create, :list => {:name => "NewList"}
end
- assert_redirected_to list_path(assigns(:list))
- end
-
- test "should show list" do
- get :show, :id => @list.to_param
- assert_response :success
- end
-
- test "should get edit" do
- get :edit, :id => @list.to_param
- assert_response :success
- end
-
- test "should update list" do
- put :update, :id => @list.to_param, :list => @list.attributes
- assert_redirected_to list_path(assigns(:list))
+ assert_redirected_to list_tasks_path(assigns(:list))
end
test "should destroy list" do
@@ -44,6 +18,6 @@ class ListsControllerTest < ActionController::TestCase
delete :destroy, :id => @list.to_param
end
- assert_redirected_to lists_path
+ assert_redirected_to root_path
end
end
View
30 test/functional/tasks_controller_test.rb
@@ -2,48 +2,34 @@
class TasksControllerTest < ActionController::TestCase
setup do
+ @list = lists(:one)
@task = tasks(:one)
end
test "should get index" do
get :index
assert_response :success
- assert_not_nil assigns(:tasks)
- end
-
- test "should get new" do
- get :new
- assert_response :success
+ assert_not_nil assigns(:lists)
end
test "should create task" do
assert_difference('Task.count') do
- post :create, :task => @task.attributes
+ post :create, :task => @task.attributes, :list_id => @list.id
end
- assert_redirected_to task_path(assigns(:task))
- end
-
- test "should show task" do
- get :show, :id => @task.to_param
- assert_response :success
- end
-
- test "should get edit" do
- get :edit, :id => @task.to_param
- assert_response :success
+ assert_redirected_to list_tasks_path(@list)
end
test "should update task" do
- put :update, :id => @task.to_param, :task => @task.attributes
- assert_redirected_to task_path(assigns(:task))
+ put :update, :id => @task.to_param, :task => @task.attributes, :list_id => @list.id
+ assert_redirected_to list_tasks_path(@list)
end
test "should destroy task" do
assert_difference('Task.count', -1) do
- delete :destroy, :id => @task.to_param
+ delete :destroy, :id => @task.to_param, :list_id => @list.id
end
- assert_redirected_to tasks_path
+ assert_redirected_to list_tasks_path(@list)
end
end
Something went wrong with that request. Please try again.