Skip to content

Instantly share code, notes, and snippets.

@TMorgan99
Created June 2, 2009 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TMorgan99/122545 to your computer and use it in GitHub Desktop.
Save TMorgan99/122545 to your computer and use it in GitHub Desktop.
build agility (generate with patches)
#!/bin/sh
# Pointer to the patch files, downloaded from github
SRC=~/Clones/hobocookbook/public/patches/agility/
# The following code is interspersed with the headings from
# the tutorial. Where there is a generator to run, I simply
# run the generator. Otherwise, I run the patch you give.
# This will allow for the generators to generate, and the patches to
# add the code, as needed.
# patch -l ( --ignore-whitespace )
# I still don't understand why some of the rails generators
# get away without ending the files in a newline.
rm -fr agility
# Getting Started
hobo agility
cd agility
# Run the app
./script/generate hobo_migration initial_users --default-name --migrate
# The models
./script/generate hobo_model_resource project name:string
./script/generate hobo_model_resource story title:string body:text status:string
./script/generate hobo_model_resource task description:string
./script/generate hobo_model task_assignment
patch -p1 -s -l -i ${SRC}12-add-initial-associations.patch
./script/generate hobo_migration initial_models --default-name --migrate
# Removing actions
patch -p1 -s -l -i ${SRC}14-remove-project-actions.patch
patch -p1 -s -l -i ${SRC}15-auto-actions-for-project.patch
patch -p1 -s -l -i ${SRC}16-auto-actions-for-story.patch
patch -p1 -s -l -i ${SRC}17-more-auto-actions.patch
# Permissions
## Introduction to permissions
## Customise the permissions in Agility
patch -p1 -s -l -i ${SRC}18-permissions-1.patch
## Permissions for data integrity
patch -p1 -s -l -i ${SRC}19-permissions-for-data-integrity.patch
## Associations
patch -p1 -s -l -i ${SRC}20-permissions-associations.patch
# Customising views
## Add assigned users to the tasks
patch -p1 -s -l -i ${SRC}22-add-users-to-tasks.patch
## Add a task summary to the user's home page
patch -p1 -s -l -i ${SRC}23-add-task-summary-to-user-page.patch
# Improve the project page with a searchable, sortable table
patch -p1 -s -l -i ${SRC}24-searchable-sortable-table.patch
patch -p1 -s -l -i ${SRC}25-stories-table-add-count.patch
patch -p1 -s -l -i ${SRC}26-stories-table-add-search.patch
# Adding User Activation
patch -p1 -s -l -i ${SRC}27-activation-lifecycle.patch
patch -p1 -s -l -i ${SRC}28-activation-transition.patch
patch -p1 -s -l -i ${SRC}29-activation-mailer.patch
patch -p1 -s -l -i ${SRC}30-setup-smtp.patch
##-- By changing the default initial state in the lifecycle, we have changed the schema
./script/generate hobo_migration user_lifecycle --default-name --migrate
patch -p1 -s -l -i ${SRC}31-display-activation-link.patch
# Odds and ends
## Story status menu
patch -p1 -s -l -i ${SRC}33-story-status-menu.patch
patch -p1 -s -l -i ${SRC}34-story-status-ajaxified.patch
## Have a configurable set of statuses
./script/generate hobo_model_resource story_status name:string
patch -p1 -s -l -i ${SRC}36-auto-actions-story-status-controller.patch
patch -p1 -s -l -i ${SRC}37-story-status-belongs-to-story.patch
./script/generate hobo_migration story_status_model --default-name --force-drop --generate
##-- Patch 39 itself needs to be patched to show the name of the migration file!
ruby -e "
TS_orig = /20090415174642_hobo_migration/
TS = /(\d+)/.match( Dir[ './db/migrate/*story_status_model.rb'].first ).captures.first
f=File.read( '${SRC}/39-story-status-model-migration-edit.patch')
puts f.gsub( TS_orig, TS )
" |patch -p1 -s -l -i -
##-- the code in the book has a typo
rake -s db:migrate
## Filtering stories by status
patch -p1 -s -l -i ${SRC}41-filtering-stories-by-status-dryml.patch
patch -p1 -s -l -i ${SRC}42-filtering-stories-by-status-css.patch
patch -p1 -s -l -i ${SRC}43-filtering-stories-by-status-controller.patch
# Task re-ordering
./script/plugin install acts_as_list
patch -p1 -s -l -i ${SRC}45-acts-as-list-model-changes.patch
./script/generate hobo_migration acts_as_list --default-name --migrate
patch -p1 -s -l -i ${SRC}47-remove-position-from-task-form.patch
patch -p1 -s -l -i ${SRC}48-fix-task-form-cancel.patch
# Markdown / Textile formatting of stories
patch -p1 -s -l -i ${SRC}49-markdown-formatting-of-stories.patch
patch -p1 -s -l -i ${SRC}50-add-bluecloth-gem.patch
rake -s gems
# Project ownership
patch -p1 -s -l -i ${SRC}51-project-belongs-to-user.patch
patch -p1 -s -l -i ${SRC}52-users-have-many-projects.patch
patch -p1 -s -l -i ${SRC}53-project-permissions.patch
./script/generate hobo_migration project_ownership --default-name --migrate
patch -p1 -s -l -i ${SRC}55-add-your-projects-to-front.patch
patch -p1 -s -l -i ${SRC}56-project-cards-without-creator-link.patch
# Granting read access to others
./script/generate hobo_model_resource project_membership
patch -p1 -s -l -i ${SRC}58-project-memberships-tweak-auto-actions.patch
patch -p1 -s -l -i ${SRC}59-project-memberships-add-associations-to-model.patch
./script/generate hobo_migration project_memberships --default-name --migrate
patch -p1 -s -l -i ${SRC}61-project-memberships-permissions.patch
patch -p1 -s -l -i ${SRC}62-project-has-many-members.patch
patch -p1 -s -l -i ${SRC}63-user-has-many-joined-projects.patch
patch -p1 -s -l -i ${SRC}64-view-permission-based-on-project-membership.patch
patch -p1 -s -l -i ${SRC}65-update-project-actions.patch
## The view layer
patch -p1 -s -l -i ${SRC}66-move-membership-to-sidebar.patch
## A form with auto-completion
patch -p1 -s -l -i ${SRC}67-auto-completion-controller.patch
patch -p1 -s -l -i ${SRC}68-auto-completion-form.patch
## Removing members
patch -p1 -s -l -i ${SRC}69-removing-members.patch
patch -p1 -s -l -i ${SRC}70-removing-members-2.patch
## Final steps
patch -p1 -s -l -i ${SRC}71-fix-front-page.patch
# At this point, give a cucumber/webrat feature file to demonstrate the
# selenium tests
## Now, add a cucumber feature layer, to replicate the acceptance tests
./script/generate cucumber
cat > ./features/create_account.feature << FEATURE
Feature: User can create account
As an agile programmer
I want to create an account for agility
So that I can use the system
Scenario: User creates account
Given No user accounts
When I go to the homepage
And I follow "Sign up"
And I fill in "user_name" with "Test User"
And I fill in "user_email_address" with "test@example.com"
And I fill in "user_password" with "test"
And I fill in "user_password_confirmation" with "test"
And I press "Signup"
Then I should see "Thanks for signing up!"
And I should see "You must activate your account before you can log in"
And I should notice the secret link
# -- attempt login before activation
When I follow "Log in"
And I fill in "login" with "test@example.com"
And I fill in "password" with "test"
And I press "Log in"
Then I should see "Account not available"
# -- login after activation
When I follow the secret activation link
And I press "Activate"
Then I should see "Assigned Tasks"
# but I am still not logged in, I see my user page
# I am 'Guest', looking at my page.
When I follow "Log in"
And I fill in "login" with "test@example.com"
And I fill in "password" with "test"
And I press "Log in"
Then I should see "You have logged in."
And I should see "Welcome to Agility"
And I should see "Your Projects"
When I follow "Log out"
Then I should see "You have logged out."
And I should see "Welcome to Agility"
And I should not see "Your Projects"
FEATURE
cat > ./features/step_definitions/agility_steps.rb << STEPS
require 'hpricot'
Given /^No user accounts$/ do
# have admin already there, you will be just a regular guy.
User.create! :name => 'Admin', :email_address => 'admin@example.com', :administrator => true
end
Then /^I should notice the secret link$/ do
doc = Hpricot( response.body )
@activation_link = ( doc % "a#activation-link" )['href']
end
When /^I follow the secret activation link$/ do
visit @activation_link
end
STEPS
rake hobo:generate_taglibs # Run the DRYML generators to generate taglibs in app/views/taglibs/auto
rake test # generates the test database
cucumber features
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment