├── .gitignore ├── README.markdown ├── Rakefile ├── app ├── controllers │ ├── application.rb │ ├── categories_controller.rb │ ├── comments_controller.rb │ ├── home_controller.rb │ ├── items_controller.rb │ ├── session_controller.rb │ ├── stars_controller.rb │ └── users_controller.rb ├── helpers │ ├── application_helper.rb │ ├── categories_helper.rb │ ├── comments_helper.rb │ ├── home_helper.rb │ ├── items_helper.rb │ ├── session_helper.rb │ └── users_helper.rb ├── models │ ├── category.rb │ ├── comment.rb │ ├── item.rb │ ├── star.rb │ └── user.rb └── views │ ├── categories │ ├── _part_of_tree.html.erb │ ├── edit.html.erb │ ├── index.html.erb │ ├── new.html.erb │ └── show.html.erb │ ├── comments │ ├── _edit_comment.html.erb │ ├── edit.html.erb │ ├── index.html.erb │ ├── new.html.erb │ └── show.html.erb │ ├── home │ ├── _signup_captcha.html.erb │ └── index.html.erb │ ├── items │ ├── _edit_item.html.erb │ ├── _item.html.erb │ ├── _paginator.html.erb │ ├── category.html.erb │ ├── edit.html.erb │ ├── index.html.erb │ ├── index.rss.builder │ ├── list_for_tags.html.erb │ ├── new.html.erb │ ├── recently.html.erb │ ├── search.html.erb │ └── show.html.erb │ ├── layouts │ ├── categories.html.erb │ ├── comments.html.erb │ ├── items.html.erb │ └── main.html.erb │ ├── session │ └── new.html.erb │ └── users │ ├── index.html.erb │ └── new.html.erb ├── config ├── boot.rb ├── database.yml.dist ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── inflections.rb │ └── mime_types.rb ├── pythonflow.yml ├── routes.rb └── rubyflow.yml ├── db ├── migrate │ ├── 001_create_users.rb │ ├── 002_add_admin_flag_to_users.rb │ ├── 003_add_open_id_authentication_tables.rb │ ├── 004_create_items.rb │ ├── 005_change_tags_to_text_on_items.rb │ ├── 006_create_categories.rb │ ├── 007_create_comments.rb │ ├── 008_add_byline_to_item.rb │ ├── 009_add_comments_count_to_items.rb │ ├── 010_user_approved_for_feed.rb │ ├── 011_create_stars.rb │ ├── 012_add_counter_cache_for_stars.rb │ ├── 013_add_id_to_stars.rb │ ├── 014_recreate_stars_table.rb │ └── 015_add_last_checked_at_to_user.rb └── schema.rb ├── lib ├── authenticated_system.rb └── authenticated_test_helper.rb ├── log └── .gitignore ├── public ├── .htaccess ├── 404.html ├── 422.html ├── 500.html ├── dispatch.cgi ├── dispatch.fcgi ├── dispatch.rb ├── favicon.ico ├── images │ └── rails.png ├── javascripts │ ├── application.js │ ├── controls.js │ ├── dragdrop.js │ ├── effects.js │ ├── jquery-ui.js │ ├── jquery.js │ ├── jrails.js │ └── prototype.js ├── robots.txt └── stylesheets │ ├── main.css │ └── scaffold.css ├── script ├── about ├── console ├── dbconsole ├── destroy ├── generate ├── performance │ ├── benchmarker │ ├── profiler │ └── request ├── plugin ├── process │ ├── inspector │ ├── reaper │ └── spawner ├── runner └── server ├── test ├── factories │ ├── item_factory.rb │ ├── misc_sequences.rb │ └── user_factory.rb ├── fixtures │ ├── categories.yml │ ├── comments.yml │ ├── items.yml │ ├── stars.yml │ └── users.yml ├── functional │ ├── comments_controller_test.rb │ ├── home_controller_test.rb │ ├── items_controller_test.rb │ ├── session_controller_test.rb │ └── users_controller_test.rb ├── integration │ └── stories_test.rb ├── test_helper.rb └── unit │ ├── category_test.rb │ ├── comment_test.rb │ ├── item_test.rb │ ├── star_test.rb │ └── user_test.rb ├── tmp └── .gitignore └── vendor └── plugins ├── acts_as_state_machine ├── CHANGELOG ├── MIT-LICENSE ├── README ├── Rakefile ├── TODO ├── init.rb ├── lib │ └── acts_as_state_machine.rb └── test │ ├── acts_as_state_machine_test.rb │ ├── database.yml │ ├── fixtures │ ├── conversation.rb │ ├── conversations.yml │ └── person.rb │ ├── schema.rb │ └── test_helper.rb ├── acts_as_tree ├── README ├── Rakefile ├── init.rb ├── lib │ └── active_record │ │ └── acts │ │ └── tree.rb └── test │ ├── abstract_unit.rb │ ├── acts_as_tree_test.rb │ ├── database.yml │ ├── fixtures │ ├── mixin.rb │ └── mixins.yml │ └── schema.rb ├── jrails ├── CHANGELOG ├── README ├── init.rb ├── install.rb ├── javascripts │ ├── jquery-ui.js │ ├── jquery.js │ ├── jrails.js │ └── sources │ │ └── jrails.js ├── lib │ └── jrails.rb └── tasks │ └── jrails.rake ├── restful_authentication ├── README ├── Rakefile ├── generators │ └── authenticated │ │ ├── USAGE │ │ ├── authenticated_generator.rb │ │ └── templates │ │ ├── activation.html.erb │ │ ├── authenticated_system.rb │ │ ├── authenticated_test_helper.rb │ │ ├── controller.rb │ │ ├── fixtures.yml │ │ ├── functional_spec.rb │ │ ├── functional_test.rb │ │ ├── helper.rb │ │ ├── login.html.erb │ │ ├── mailer.rb │ │ ├── mailer_test.rb │ │ ├── migration.rb │ │ ├── model.rb │ │ ├── model_controller.rb │ │ ├── model_functional_spec.rb │ │ ├── model_functional_test.rb │ │ ├── model_helper.rb │ │ ├── observer.rb │ │ ├── signup.html.erb │ │ ├── signup_notification.html.erb │ │ ├── unit_spec.rb │ │ └── unit_test.rb ├── install.rb └── lib │ └── restful_authentication │ └── rails_commands.rb └── shoulda ├── .autotest ├── .gitignore ├── CONTRIBUTION_GUIDELINES.rdoc ├── MIT-LICENSE ├── README.rdoc ├── Rakefile ├── bin └── convert_to_should_syntax ├── init.rb ├── lib ├── shoulda.rb └── shoulda │ ├── active_record_helpers.rb │ ├── color.rb │ ├── controller_tests │ ├── controller_tests.rb │ └── formats │ │ ├── html.rb │ │ └── xml.rb │ ├── gem │ ├── proc_extensions.rb │ └── shoulda.rb │ ├── general.rb │ └── private_helpers.rb ├── tasks ├── list_tests.rake └── yaml_to_shoulda.rake └── test ├── README ├── fixtures ├── addresses.yml ├── posts.yml ├── products.yml ├── taggings.yml ├── tags.yml └── users.yml ├── functional ├── posts_controller_test.rb └── users_controller_test.rb ├── other ├── context_test.rb ├── convert_to_should_syntax_test.rb ├── helpers_test.rb ├── private_helpers_test.rb └── should_test.rb ├── rails_root ├── app │ ├── controllers │ │ ├── application.rb │ │ ├── posts_controller.rb │ │ └── users_controller.rb │ ├── helpers │ │ ├── application_helper.rb │ │ ├── posts_helper.rb │ │ └── users_helper.rb │ ├── models │ │ ├── address.rb │ │ ├── dog.rb │ │ ├── flea.rb │ │ ├── post.rb │ │ ├── product.rb │ │ ├── tag.rb │ │ ├── tagging.rb │ │ └── user.rb │ └── views │ │ ├── layouts │ │ ├── posts.rhtml │ │ └── users.rhtml │ │ ├── posts │ │ ├── edit.rhtml │ │ ├── index.rhtml │ │ ├── new.rhtml │ │ └── show.rhtml │ │ └── users │ │ ├── edit.rhtml │ │ ├── index.rhtml │ │ ├── new.rhtml │ │ └── show.rhtml ├── config │ ├── boot.rb │ ├── database.yml │ ├── environment.rb │ ├── environments │ │ └── sqlite3.rb │ ├── initializers │ │ ├── new_rails_defaults.rb │ │ └── shoulda.rb │ └── routes.rb ├── db │ ├── migrate │ │ ├── 001_create_users.rb │ │ ├── 002_create_posts.rb │ │ ├── 003_create_taggings.rb │ │ ├── 004_create_tags.rb │ │ ├── 005_create_dogs.rb │ │ ├── 006_create_addresses.rb │ │ ├── 007_create_fleas.rb │ │ ├── 008_create_dogs_fleas.rb │ │ └── 009_create_products.rb │ └── schema.rb ├── log │ └── .keep ├── public │ ├── .htaccess │ ├── 404.html │ ├── 422.html │ └── 500.html ├── script │ ├── console │ └── generate └── vendor │ └── plugins │ └── .keep ├── test_helper.rb └── unit ├── address_test.rb ├── dog_test.rb ├── flea_test.rb ├── post_test.rb ├── product_test.rb ├── tag_test.rb ├── tagging_test.rb └── user_test.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | log/*.log 3 | log/*.pid 4 | #config/development.sphinx.conf 5 | tmp/**/* 6 | config/database.yml 7 | db/*.sqlite3 8 | coverage 9 | doc/plugins/* 10 | doc/* 11 | #db/sphinx/development/* 12 | Capfile -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | RUBYFLOW 2 | ======== 3 | _Developed by Peter Cooper - 2008_ 4 | 5 | All code developed by Peter Cooper within this project is in the public domain. 6 | Plugins, Rails, and derivative code is licensed as it was originally (mostly MIT). 7 | 8 | This code is entirely unsupported, lacks tests, and could well make your machine 9 | explode. If you use it, you understand this and accept all the risks. 10 | 11 | 12 | Getting Started 13 | --------------- 14 | I have not tested these instructions, but from memory.. 15 | 16 | 1. Rename config/database.yml.dist to database.yml and make the appropriate 17 | configuration changes. 18 | 19 | 2. Run rake db:migrate to set up your database. 20 | 21 | 3. Configure your site-specific settings (see "Multiple Sites", below). 22 | 23 | Multiple Sites 24 | -------------- 25 | 26 | The RubyFlow code is designed to deal with multiple sites from one codebase (although not one installation). 27 | The settings for a particular site are in config/[sitename].yml 28 | The site name for the current installation is set on the first line of config/environment.rb 29 | Current the setting is for "rubyflow", so config/rubyflow.yml is used. 30 | Change the chosen site in config/environment.rb and create your own YML file. 31 | 32 | Note that the chosen site name is added as a class to the BODY tag. This makes it easy to use the same 33 | CSS file for multiple sites but apply site specific tweaks with BODY.sitename prefixes in the CSS! -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require(File.join(File.dirname(__FILE__), 'config', 'boot')) 5 | 6 | require 'rake' 7 | require 'rake/testtask' 8 | require 'rake/rdoctask' 9 | 10 | require 'tasks/rails' 11 | -------------------------------------------------------------------------------- /app/controllers/application.rb: -------------------------------------------------------------------------------- 1 | # Filters added to this controller apply to all controllers in the application. 2 | # Likewise, all the methods added will be available for all controllers. 3 | 4 | class ApplicationController < ActionController::Base 5 | helper :all # include all helpers, all the time 6 | 7 | # See ActionController::RequestForgeryProtection for details 8 | # Uncomment the :secret if you're not using the cookie session store 9 | protect_from_forgery # :secret => '????? you'll need to sort this out yourself!' 10 | 11 | include AuthenticatedSystem 12 | 13 | def go_404 14 | render :text => '404 Not Found', :status => 404 15 | end 16 | 17 | def items_per_page 18 | 50 19 | end 20 | helper_method :items_per_page 21 | 22 | # do_pagination is used in before_filters by actions that use pagination 23 | # If a "page" param is provided, use that to set the page, otherwise assume we're on page 1 24 | # Then set up a pagination_options hash that can be used with 'find' to sort out the SQL! 25 | # If param "all" is set, pagination is forgotten and ALL items should be returned 26 | def do_pagination 27 | @page_number = 1 28 | if params[:page] && params[:page].to_i > 0 29 | @page_number = params[:page].to_i 30 | end 31 | @pagination = true 32 | @pagination_options = { :limit => items_per_page, :offset => (@page_number - 1) * items_per_page } 33 | @pagination_options = {} if params[:all] 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /app/controllers/categories_controller.rb: -------------------------------------------------------------------------------- 1 | class CategoriesController < ApplicationController 2 | # You need to be an admin to play with categories (not actually used in this app yet) 3 | before_filter :admin_required, :except => [:show, :index] 4 | 5 | layout 'main' 6 | 7 | # GET /categories 8 | # GET /categories.xml 9 | def index 10 | @top_category = Category.find_by_parent_id(nil) 11 | 12 | respond_to do |format| 13 | format.html # index.html.erb 14 | format.xml { render :xml => Category.find(:all) } 15 | end 16 | end 17 | 18 | # GET /categories/1 19 | # GET /categories/1.xml 20 | def show 21 | @category = Category.find(params[:id]) rescue Category.find_by_name(params[:id]) 22 | 23 | respond_to do |format| 24 | format.html # show.html.erb 25 | format.xml { render :xml => @category } 26 | end 27 | end 28 | 29 | # GET /categories/new 30 | # GET /categories/new.xml 31 | def new 32 | @category = Category.new 33 | 34 | respond_to do |format| 35 | format.html # new.html.erb 36 | format.xml { render :xml => @category } 37 | end 38 | end 39 | 40 | # GET /categories/1/edit 41 | def edit 42 | @category = Category.find(params[:id]) rescue Category.find_by_name(params[:id]) 43 | end 44 | 45 | # POST /categories 46 | # POST /categories.xml 47 | def create 48 | @category = Category.new(params[:category]) 49 | 50 | respond_to do |format| 51 | if @category.save 52 | flash[:notice] = 'Category was successfully created.' 53 | format.html { redirect_to(@category) } 54 | format.xml { render :xml => @category, :status => :created, :location => @category } 55 | else 56 | format.html { render :action => "new" } 57 | format.xml { render :xml => @category.errors, :status => :unprocessable_entity } 58 | end 59 | end 60 | end 61 | 62 | # PUT /categories/1 63 | # PUT /categories/1.xml 64 | def update 65 | @category = Category.find(params[:id]) rescue Category.find_by_name(params[:id]) 66 | 67 | respond_to do |format| 68 | if @category.update_attributes(params[:category]) 69 | flash[:notice] = 'Category was successfully updated.' 70 | format.html { redirect_to(@category) } 71 | format.xml { head :ok } 72 | else 73 | format.html { render :action => "edit" } 74 | format.xml { render :xml => @category.errors, :status => :unprocessable_entity } 75 | end 76 | end 77 | end 78 | 79 | # DELETE /categories/1 80 | # DELETE /categories/1.xml 81 | def destroy 82 | @category = Category.find(params[:id]) rescue Category.find_by_name(params[:id]) 83 | @category.destroy 84 | 85 | respond_to do |format| 86 | format.html { redirect_to(categories_url) } 87 | format.xml { head :ok } 88 | end 89 | end 90 | end 91 | -------------------------------------------------------------------------------- /app/controllers/comments_controller.rb: -------------------------------------------------------------------------------- 1 | class CommentsController < ApplicationController 2 | before_filter :admin_required, :except => [:create] 3 | before_filter :load_item 4 | 5 | layout 'main' 6 | 7 | # GET /comments/1/edit 8 | def edit 9 | @comment = Comment.find(params[:id]) 10 | end 11 | 12 | # POST /comments 13 | # POST /comments.xml 14 | def create 15 | @comment = Comment.new(params[:comment]) 16 | @comment.item = @item 17 | 18 | if logged_in? 19 | @comment.user = current_user 20 | else 21 | @comment.byline = "Anonymous Coward" if @comment.byline.empty? 22 | @comment.content = @comment.content.gsub(/((]*?)>)/, '\2 rel="nofollow" \3>') 23 | unless Digest::SHA1.hexdigest(params[:captcha].upcase.chomp)[0..5] == params[:captcha_guide] 24 | @item.errors.add("Word") 25 | flash.now[:notice] = "Your comment could not be posted. Scroll down, correct, and retry. Did you get the CAPTCHA right?" 26 | render :template => 'items/show' 27 | return 28 | end 29 | end 30 | 31 | respond_to do |format| 32 | if @comment.save 33 | flash[:notice] = 'Comment was successfully created.' 34 | format.html { redirect_to(@comment.item) } 35 | format.xml { render :xml => @comment, :status => :created, :location => @comment } 36 | else 37 | flash.now[:notice] = "Your comment could not be posted. Scroll down, correct, and retry." 38 | format.html { render :template => 'items/show' } 39 | format.xml { render :xml => @comment.errors, :status => :unprocessable_entity } 40 | end 41 | end 42 | end 43 | 44 | # PUT /comments/1 45 | # PUT /comments/1.xml 46 | def update 47 | @comment = Comment.find(params[:id]) 48 | 49 | respond_to do |format| 50 | if @comment.update_attributes(params[:comment]) 51 | flash[:notice] = 'Comment was successfully updated.' 52 | format.html { redirect_to(@comment) } 53 | format.xml { head :ok } 54 | else 55 | format.html { render :action => "edit" } 56 | format.xml { render :xml => @comment.errors, :status => :unprocessable_entity } 57 | end 58 | end 59 | end 60 | 61 | # DELETE /comments/1 62 | # DELETE /comments/1.xml 63 | def destroy 64 | @comment = Comment.find(params[:id]) 65 | @comment.destroy 66 | 67 | respond_to do |format| 68 | format.html { redirect_to(comments_url) } 69 | format.xml { head :ok } 70 | end 71 | end 72 | 73 | private 74 | def load_item 75 | @item = Item.find(params[:item_id]) 76 | end 77 | end 78 | -------------------------------------------------------------------------------- /app/controllers/home_controller.rb: -------------------------------------------------------------------------------- 1 | class HomeController < ApplicationController 2 | layout 'main' 3 | 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/session_controller.rb: -------------------------------------------------------------------------------- 1 | # This controller handles the login/logout function of the site. 2 | class SessionController < ApplicationController 3 | layout 'main' 4 | 5 | def new 6 | end 7 | 8 | def create 9 | #if using_open_id? 10 | # open_id_authentication(params[:openid_url]) 11 | #else 12 | password_authentication(params[:login], params[:password]) 13 | #end 14 | end 15 | 16 | def destroy 17 | self.current_user.forget_me if logged_in? 18 | cookies.delete :auth_token 19 | reset_session 20 | flash[:notice] = "You have been logged out." 21 | redirect_back_or_default('/') 22 | end 23 | 24 | protected 25 | 26 | def open_id_authentication(openid_url) 27 | authenticate_with_open_id(openid_url, :required => [:nickname, :email]) do |result, identity_url, registration| 28 | if result.successful? 29 | @user = User.find_or_initialize_by_identity_url(identity_url) 30 | if @user.new_record? 31 | @user.login = registration['nickname'] 32 | @user.email = registration['email'] 33 | @user.save(false) 34 | end 35 | self.current_user = @user 36 | successful_login 37 | else 38 | failed_login result.message 39 | end 40 | end 41 | end 42 | 43 | def password_authentication(login, password) 44 | self.current_user = User.authenticate(login, password) 45 | if logged_in? 46 | successful_login 47 | else 48 | failed_login 49 | end 50 | end 51 | 52 | def failed_login(message = "Authentication failed.") 53 | flash.now[:error] = message 54 | render :action => 'new' 55 | end 56 | 57 | def successful_login 58 | if params[:remember_me] == "1" 59 | self.current_user.remember_me 60 | cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => 1.year.from_now } 61 | end 62 | redirect_back_or_default('/') 63 | flash[:notice] = "Logged in successfully" 64 | end 65 | 66 | end 67 | -------------------------------------------------------------------------------- /app/controllers/stars_controller.rb: -------------------------------------------------------------------------------- 1 | class StarsController < ApplicationController 2 | 3 | skip_before_filter :verify_authenticity_token 4 | before_filter :login_required 5 | 6 | def add 7 | @item = Item.find(params[:item_id]) 8 | @star = Star.new(:item => @item, :user => current_user) 9 | saved = @star.save 10 | respond_to do |wants| 11 | wants.html { redirect_to :back } 12 | wants.js do 13 | stars_count = @item.stars.size + 1 14 | saved ? render(:text => "#{stars_count} #{stars_count == 1 ? "star" : "stars"}") : head(:unprocessable_entity) 15 | end 16 | end 17 | end 18 | 19 | def remove 20 | @item = Item.find(params[:item_id]) 21 | @star = @item.stars.find(:first, :conditions => ["user_id = ?", current_user.id]) 22 | destroyed = @star ? @star.destroy : false # If the star doesn't exist, add it 23 | respond_to do |wants| 24 | wants.html { redirect_to :back } 25 | wants.js do 26 | stars_count = @item.stars.size - 1 27 | destroyed ? render(:text => "#{stars_count} #{stars_count == 1 ? "star" : "stars"}") : head(:unprocessable_entity) 28 | end 29 | end 30 | end 31 | 32 | end -------------------------------------------------------------------------------- /app/controllers/users_controller.rb: -------------------------------------------------------------------------------- 1 | class UsersController < ApplicationController 2 | before_filter :admin_required, :except => [:new, :create] 3 | 4 | layout 'main' 5 | 6 | def new 7 | end 8 | 9 | def create 10 | cookies.delete :auth_token 11 | 12 | @user = User.new(params[:user]) 13 | unless Digest::SHA1.hexdigest(params[:captcha].upcase.chomp)[0..5] == params[:captcha_guide] 14 | @user.errors.add("Word") 15 | render :action => 'new' 16 | return 17 | end 18 | 19 | @user.save 20 | if @user.errors.empty? 21 | self.current_user = @user 22 | redirect_back_or_default('/') 23 | flash[:notice] = "Thanks for signing up! You have been logged in automagically!" 24 | else 25 | render :action => 'new' 26 | end 27 | end 28 | 29 | def index 30 | @users = User.find(:all, :order => 'id DESC', :limit => 100) 31 | end 32 | 33 | def approve 34 | user = User.find(params[:id]) 35 | user.approved_for_feed = 1 36 | user.save 37 | redirect_to :back 38 | end 39 | 40 | def disapprove 41 | user = User.find(params[:id]) 42 | user.approved_for_feed = 0 43 | user.save 44 | redirect_to :back 45 | end 46 | 47 | def destroy 48 | return unless request.post? 49 | User.destroy(params[:id]) 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | # Methods added to this helper will be available to all templates in the application. 2 | module ApplicationHelper 3 | def editable?(item) 4 | admin? || item.user == current_user 5 | end 6 | 7 | def title 8 | if @title 9 | @title + " : " + APP_CONFIG[:app_title] 10 | else 11 | APP_CONFIG[:default_title] 12 | end 13 | end 14 | 15 | def safe(txt) 16 | sanitize(txt, :tags => %w(a p code b strong i em blockquote), :attributes => %w(href)).split("\n").join("\n
") 17 | end 18 | 19 | end 20 | -------------------------------------------------------------------------------- /app/helpers/categories_helper.rb: -------------------------------------------------------------------------------- 1 | module CategoriesHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/comments_helper.rb: -------------------------------------------------------------------------------- 1 | module CommentsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/home_helper.rb: -------------------------------------------------------------------------------- 1 | module HomeHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/items_helper.rb: -------------------------------------------------------------------------------- 1 | module ItemsHelper 2 | def user_link(item) 3 | if item.user 4 | follow = item.user.approved_for_feed == 1 ? {} : {:rel => 'nofollow'} 5 | link_to(item.user.login, item.user.url, follow) 6 | else 7 | item.byline 8 | end 9 | end 10 | 11 | def star_link(item) 12 | if item.is_starred_by_user(current_user) 13 | return " – " + content_tag(:span, link_to("unstar this post", item_remove_star_path(item), :class => item.starred_class(current_user)), :class => "star") 14 | end 15 | end 16 | 17 | # Shows the time left to edit the current item, or nil if it's always allowed 18 | def edit_time_left(item) 19 | diff = Time.now - item.updated_at 20 | expire_rate = APP_CONFIG[:edit_expiration_in_minutes].to_i 21 | return expire_rate > 0 ? expire_rate - (diff.to_i / 60) : nil 22 | end 23 | 24 | end 25 | -------------------------------------------------------------------------------- /app/helpers/session_helper.rb: -------------------------------------------------------------------------------- 1 | module SessionHelper 2 | end -------------------------------------------------------------------------------- /app/helpers/users_helper.rb: -------------------------------------------------------------------------------- 1 | module UsersHelper 2 | end -------------------------------------------------------------------------------- /app/models/category.rb: -------------------------------------------------------------------------------- 1 | class Category < ActiveRecord::Base 2 | acts_as_tree :order => 'name' 3 | 4 | validates_presence_of :title, :parent_id 5 | validates_length_of :title, :within => 4..255 6 | 7 | validates_uniqueness_of :name, :if => :name? 8 | validates_format_of :name, :with => /^[\w\-\_]+$/, :if => :name?, :message => 'is invalid (alphanumerics, hyphens and underscores only)' 9 | validates_length_of :name, :within => 4..255, :if => :name? 10 | 11 | def to_param 12 | self[:name] && self[:name].length > 3 ? self[:name] : self[:id] 13 | end 14 | 15 | def publicly_facing_name 16 | title && title.length > 2 ? title : name 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /app/models/comment.rb: -------------------------------------------------------------------------------- 1 | class Comment < ActiveRecord::Base 2 | belongs_to :item, :counter_cache => true 3 | belongs_to :user 4 | 5 | validates_length_of :content, :within => 1..10000 6 | end 7 | -------------------------------------------------------------------------------- /app/models/item.rb: -------------------------------------------------------------------------------- 1 | class Item < ActiveRecord::Base 2 | belongs_to :user 3 | has_many :comments 4 | has_many :stars, :dependent => :destroy 5 | 6 | serialize :metadata 7 | 8 | attr_protected :user_id 9 | 10 | validates_length_of :title, :within => 4..255 11 | validates_uniqueness_of :name, :if => :name? 12 | validates_format_of :name, :with => /^[\w\-\_]+$/, :if => :name?, :message => 'is invalid (alphanumerics, hyphens and underscores only)' 13 | validates_length_of :name, :within => 4..255, :if => :name? 14 | validates_length_of :content, :within => 25..1200 15 | validates_format_of :tags, :with => /^[\s\w\-\_\:]+$/, :if => :tags?, :message => 'are invalid (alphanumerics, hyphens and underscores only)' 16 | 17 | def to_param 18 | self[:name] && self[:name].length > 3 ? self[:name] : self[:id] 19 | end 20 | 21 | def tags=(tag_set) 22 | self[:tags] = tag_set.split.collect { |a| " :#{a} " }.join 23 | end 24 | 25 | def tags_before_type_cast 26 | self[:tags].to_s.gsub(':', '').gsub(/[^\w\s\-\_\:].+?\s+/, ' ').gsub(/[^\w\s\-\_\:]/, '').strip.split(/\s+/).join(' ') 27 | end 28 | 29 | def tags 30 | tags_before_type_cast 31 | end 32 | 33 | def tag_array 34 | tags.split(/\s+/) 35 | end 36 | 37 | def self.find_all_for_all_tags(tags, options = {}) 38 | find(:all, { :conditions => [[*tags].collect { "tags LIKE ?" }.join(" AND "), *[*tags].collect { |a| "%:#{a} %" }] }.merge(options)) 39 | end 40 | 41 | def self.count_all_for_all_tags(tags, options = {}) 42 | count({ :conditions => [[*tags].collect { "tags LIKE ?" }.join(" AND "), *[*tags].collect { |a| "%:#{a} %" }] }.merge(options)) 43 | end 44 | 45 | def self.find_all_for_tag(tag, options = {}) 46 | find(:all, { :conditions => ["tags LIKE ?", "%#{tag}%"] }.merge(options)) 47 | end 48 | 49 | def self.count_all_for_tag(tag, options = {}) 50 | count({ :conditions => ["tags LIKE ?", "%#{tag}%"] }.merge(options)) 51 | end 52 | 53 | def self.find_all_for_tags(tags, options = {}) 54 | find(:all, { :conditions => [[*tags].collect { "tags LIKE ?" }.join(" OR "), *[*tags].collect { |a| "%:#{a} %" }] }.merge(options)) 55 | end 56 | def self.count_all_for_tags(tags, options = {}) 57 | count({ :conditions => [[*tags].collect { "tags LIKE ?" }.join(" OR "), *[*tags].collect { |a| "%:#{a} %" }] }.merge(options)) 58 | end 59 | 60 | def is_starred_by_user(user) 61 | user.starred_items.include? self 62 | end 63 | 64 | # TODO move to a helper 65 | def starred_class(user) 66 | if self.is_starred_by_user(user) 67 | return "starred" 68 | else 69 | return "" 70 | end 71 | end 72 | end 73 | -------------------------------------------------------------------------------- /app/models/star.rb: -------------------------------------------------------------------------------- 1 | class Star < ActiveRecord::Base 2 | 3 | belongs_to :user 4 | belongs_to :item, :counter_cache => true 5 | 6 | # Prevent people starring something multiple times. 7 | validates_uniqueness_of :item_id, :scope => :user_id, :on => :create, :message => "must be unique" 8 | 9 | end 10 | -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | require 'digest/sha1' 2 | class User < ActiveRecord::Base 3 | has_many :stars 4 | has_many :starred_items, :through => :stars, :source => :item 5 | # Virtual attribute for the unencrypted password 6 | attr_accessor :password 7 | 8 | validates_presence_of :login #, :email 9 | validates_presence_of :password, :if => :password_required? 10 | validates_presence_of :password_confirmation, :if => :password_required? 11 | validates_length_of :password, :within => 4..40, :if => :password_required? 12 | validates_confirmation_of :password, :if => :password_required? 13 | validates_length_of :login, :within => 3..40 14 | #validates_length_of :email, :within => 3..100 15 | validates_uniqueness_of :login, :case_sensitive => false 16 | validates_format_of :login, :with => /^\w+$/ 17 | validates_format_of :url, :with => /^(|http\:\/\/.*)$/ 18 | before_save :encrypt_password 19 | 20 | # prevents a user from submitting a crafted form that bypasses activation 21 | # anything else you want your user to change should be added here. 22 | attr_accessible :login, :email, :password, :password_confirmation, :identity_url, :url, :fullname 23 | 24 | # Authenticates a user by their login name and unencrypted password. Returns the user or nil. 25 | def self.authenticate(login, password) 26 | u = find_by_login(login) # need to get the salt 27 | u && u.authenticated?(password) ? u : nil 28 | end 29 | 30 | # Encrypts some data with the salt. 31 | def self.encrypt(password, salt) 32 | Digest::SHA1.hexdigest("--#{salt}--#{password}--") 33 | end 34 | 35 | # Encrypts the password with the user salt 36 | def encrypt(password) 37 | self.class.encrypt(password, salt) 38 | end 39 | 40 | def authenticated?(password) 41 | crypted_password == encrypt(password) 42 | end 43 | 44 | def remember_token? 45 | remember_token_expires_at && Time.now.utc < remember_token_expires_at 46 | end 47 | 48 | # These create and unset the fields required for remembering users between browser closes 49 | def remember_me 50 | remember_me_for 52.weeks 51 | end 52 | 53 | def remember_me_for(time) 54 | remember_me_until time.from_now.utc 55 | end 56 | 57 | def remember_me_until(time) 58 | self.remember_token_expires_at = time 59 | self.remember_token = encrypt("#{email}--#{remember_token_expires_at}") 60 | save(false) 61 | end 62 | 63 | def forget_me 64 | self.remember_token_expires_at = nil 65 | self.remember_token = nil 66 | save(false) 67 | end 68 | 69 | protected 70 | # before filter 71 | def encrypt_password 72 | return if password.blank? 73 | self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record? 74 | self.crypted_password = encrypt(password) 75 | end 76 | 77 | def password_required? 78 | crypted_password.blank? || !password.blank? 79 | end 80 | 81 | 82 | end 83 | -------------------------------------------------------------------------------- /app/views/categories/_part_of_tree.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <% current_category.children.each do |category| %> 3 |

<%= link_to h(category.publicly_facing_name), category %> 4 | <%= link_to('Edit', edit_category_path(category)) if admin? %> 5 | <%= link_to('Destroy', category, :confirm => 'Are you sure?', :method => :delete) if admin? %>

6 | <%= render :partial => 'part_of_tree', :locals => { :current_category => category } if category.children && !category.children.empty? %> 7 | <% end %> 8 |
-------------------------------------------------------------------------------- /app/views/categories/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing category

2 | 3 | <%= error_messages_for :category %> 4 | 5 | <% form_for(@category) do |f| %> 6 |

7 | Name
8 | <%= f.text_field :name %> 9 |

10 | 11 |

12 | Title
13 | <%= f.text_field :title %> 14 |

15 | 16 |

17 | Parent Category
18 | <%= select_tag "category[parent_id]", options_for_select(Category.find(:all).collect { |c| [c.publicly_facing_name + " (#{c.name})", c.id] }, @category.parent_id) %> 19 |

20 | 21 |

22 | Query
23 | <%= f.text_field :query %> 24 |

25 | 26 |

27 | <%= f.submit "Update" %> 28 |

29 | <% end %> 30 | 31 | <%= link_to 'Show', @category %> | 32 | <%= link_to 'Back', categories_path %> 33 | -------------------------------------------------------------------------------- /app/views/categories/index.html.erb: -------------------------------------------------------------------------------- 1 |

Listing categories

2 | 3 | 4 | <%= render :partial => 'part_of_tree', :locals => { :current_category => @top_category } %> 5 | 6 |
7 | 8 | <%= link_to 'New category', new_category_path if admin? %> 9 | -------------------------------------------------------------------------------- /app/views/categories/new.html.erb: -------------------------------------------------------------------------------- 1 |

New category

2 | 3 | <%= error_messages_for :category %> 4 | 5 | <% form_for(@category) do |f| %> 6 |

7 | Name
8 | <%= f.text_field :name %> 9 |

10 | 11 |

12 | Title
13 | <%= f.text_field :title %> 14 |

15 | 16 |

17 | Parent Category
18 | <%= select_tag "category[parent_id]", options_for_select(Category.find(:all).collect { |c| [c.name, c.id] }) %> 19 |

20 | 21 |

22 | Query
23 | <%= f.text_field :query %> 24 |

25 | 26 |

27 | <%= f.submit "Create" %> 28 |

29 | <% end %> 30 | 31 | <%= link_to 'Back', categories_path %> 32 | -------------------------------------------------------------------------------- /app/views/categories/show.html.erb: -------------------------------------------------------------------------------- 1 |

2 | Name: 3 | <%=h @category.name %> 4 |

5 | 6 |

7 | Title: 8 | <%=h @category.title %> 9 |

10 | 11 |

12 | Parent: 13 | <% if @category.parent %><%=h @category.parent.name %><% end %> 14 |

15 | 16 |

17 | Query: 18 | <%=h @category.query %> 19 |

20 | 21 | 22 | <%= link_to 'Edit', edit_category_path(@category) %> | 23 | <%= link_to 'Back', categories_path %> 24 | -------------------------------------------------------------------------------- /app/views/comments/_edit_comment.html.erb: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | <% form_for [item, comment] do |f| %> 5 | 6 |

Post a Comment

7 | 8 | <% if comment.errors.size > 0 %> 9 |

Error! Your comment is too long or too short.

10 | <% end %> 11 | 12 | 13 | <% if logged_in? %> 14 |

Posting as <%= current_user.login %>

15 | <% else %> 16 |

Note: If you are a registered user, <%= link_to 'log in', login_url %> to populate these fields.

17 |

<%= f.text_field :byline %> 18 |

19 | <% end %> 20 | 21 |

22 | If you wish, you may use these HTML tags to format your comment:
23 | 24 | <a href="" title=""> <b> <blockquote> <code> <em> <i> <strong> 25 | 26 |

27 |

<%= f.text_area :content %>

28 | 29 | <%= render :partial => 'home/signup_captcha' unless logged_in? %> 30 | 31 |

<%= f.submit "Post Comment" %>

32 | <% end %> 33 | 34 |
35 | -------------------------------------------------------------------------------- /app/views/comments/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing comment

2 | 3 | <%= error_messages_for :comment %> 4 | 5 | <% form_for(@comment) do |f| %> 6 |

7 | Content
8 | <%= f.text_area :content %> 9 |

10 | 11 |

12 | Byline
13 | <%= f.text_field :byline %> 14 |

15 | 16 |

17 | User
18 | <%= f.text_field :user %> 19 |

20 | 21 |

22 | <%= f.submit "Update" %> 23 |

24 | <% end %> 25 | 26 | <%= link_to 'Show', @comment %> | 27 | <%= link_to 'Back', comments_path %> 28 | -------------------------------------------------------------------------------- /app/views/comments/index.html.erb: -------------------------------------------------------------------------------- 1 |

Listing comments

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | <% for comment in @comments %> 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | <% end %> 20 |
ContentBylineUser
<%=h comment.content %><%=h comment.byline %><%=h comment.user %><%= link_to 'Show', comment %><%= link_to 'Edit', edit_comment_path(comment) %><%= link_to 'Destroy', comment, :confirm => 'Are you sure?', :method => :delete %>
21 | 22 |
23 | 24 | <%= link_to 'New comment', new_comment_path %> 25 | -------------------------------------------------------------------------------- /app/views/comments/new.html.erb: -------------------------------------------------------------------------------- 1 |

New comment

2 | 3 | <%= error_messages_for :comment %> 4 | 5 | <% form_for(@comment) do |f| %> 6 |

7 | Content
8 | <%= f.text_area :content %> 9 |

10 | 11 |

12 | Byline
13 | <%= f.text_field :byline %> 14 |

15 | 16 |

17 | <%= f.submit "Create" %> 18 |

19 | <% end %> 20 | 21 | <%= link_to 'Back', comments_path %> 22 | -------------------------------------------------------------------------------- /app/views/comments/show.html.erb: -------------------------------------------------------------------------------- 1 |

2 | Content: 3 | <%=h @comment.content %> 4 |

5 | 6 |

7 | Byline: 8 | <%=h @comment.byline %> 9 |

10 | 11 |

12 | User: 13 | <%=h @comment.user.login %> 14 |

15 | 16 | 17 | <%= link_to 'Edit', edit_comment_path(@comment) %> | 18 | <%= link_to 'Back', comments_path %> 19 | -------------------------------------------------------------------------------- /app/views/home/_signup_captcha.html.erb: -------------------------------------------------------------------------------- 1 |

2 | <% words = %w{renegade nevergonna giveyouup letyoudown runaround starla luckystiff inside an at ax al pol paypal nidd nid pin pit pragmatic astley twogirls onecup felch kwyjibo covenham kenwick grimsby warlingham cooper macbook triumph air mascot football hockey tennis shadow bullet metaphor flyer twitter yahoo google coding ruby masterplan spyhole porthole boat float granite trousers dragon tiger} %> 3 | <% post_words = %w{in ox et by rat tar al s ty ax ak an at de er ers} %> 4 |

<% random_word = words[rand(words.size)] + post_words[rand(post_words.size)]; random_word.each_byte do |char| %><%= char.chr.upcase %><%= %Q{#{char.chr.upcase}} if rand(3) == 0 %><% end %>

5 |
6 | <%= text_field_tag "captcha" %> 7 | <%= hidden_field_tag "captcha_guide", Digest::SHA1.hexdigest(random_word.upcase)[0..5] %> 8 |

9 | -------------------------------------------------------------------------------- /app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 |

Welcome

2 | 3 | <% if logged_in? %> 4 |

You are logged in as <%=h current_user.login %>

5 | <%= "you are admin" if admin? %> 6 | 7 | <% else %> 8 |

You are not logged in.

9 | <% end %> -------------------------------------------------------------------------------- /app/views/items/_edit_item.html.erb: -------------------------------------------------------------------------------- 1 | <% form_for(item) do |f| %> 2 | <%= error_messages_for :item %> 3 | 4 |
5 | 6 | 7 | 8 | <% if logged_in? %> 9 |

Posting as <%= current_user.login %>

10 | <% else %> 11 |

12 | Note: If you are a registered user, <%= link_to 'log in', login_url %> to populate these fields automatically. 13 |

14 |

15 | <%= f.text_field :byline %> 16 | 17 |

18 | <% end %> 19 | 20 |

21 | <%= f.text_field :title %> 22 | 23 |

24 | 25 |

26 | If you wish, you may use these HTML tags to format your post:
27 | 28 | <a href=""> <b> <blockquote> <code> <em> <i> <strong> 29 | 30 |

31 | Yes, you must use HTML and not Textile or Markdown for now. 32 |

33 | 34 |

<%= f.text_area :content, :cols => 60, :rows => 8 %>

35 | 36 | <%= render :partial => 'home/signup_captcha' unless logged_in? %> 37 | 38 |

<%= f.submit "#{method == 'post' ? 'Post' : 'Update'} Item" %>

39 |
40 | <% end %> -------------------------------------------------------------------------------- /app/views/items/_item.html.erb: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | <%= auto_link(safe(item.content)) %> 5 | 6 |
7 | 8 | 15 | 16 | <% div_for(item, :class => "admin-actions") do %> 17 | <% if admin? %> 18 | <%= link_to 'Remove', item, :confirm => 'Are you sure?', :method => :delete %> 19 | <% end %> 20 | 21 | <% time_left = edit_time_left(item) %> 22 | <% if admin? || (item.user == current_user && (time_left.nil? || time_left > 0)) %> 23 | <%= link_to 'Edit', edit_item_path(item), 24 | :title => "Last chance of editing ends #{time_left.nil? ? 'never' : ('in ' + time_left.to_s + ' minutes')}." %> 25 | <% end %> 26 | <% end %> 27 |
28 | -------------------------------------------------------------------------------- /app/views/items/_paginator.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <% if @page_number > 1 %> 3 | 4 | <% end %> 5 | <% if @items_count > (@page_number * items_per_page) %> 6 | 7 | <% end %> 8 |
9 | -------------------------------------------------------------------------------- /app/views/items/category.html.erb: -------------------------------------------------------------------------------- 1 |

<%= @category.title %>

2 | 3 | <% for item in @items %> 4 | <%=h item.title %>
5 | <%=h item.url %>
6 | <%=h item.content %>
7 | <%=h item.metadata %>
8 | <%=h item.name %>
9 | <%=h item.tags %>
10 | <%=h item.user_id %>
11 | <%= link_to 'Show', item %>
12 | <%= link_to 'Edit', edit_item_path(item) %>
13 | <%= link_to 'Destroy', item, :confirm => 'Are you sure?', :method => :delete %>
14 | <% end %> 15 | -------------------------------------------------------------------------------- /app/views/items/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing item

2 | 3 | 4 | <%= render :partial => 'edit_item', :locals => { :item => @item, :method => 'put' } %> 5 | 6 | <%= link_to 'Show', @item %> | 7 | <%= link_to 'Back', items_path %> 8 | -------------------------------------------------------------------------------- /app/views/items/index.html.erb: -------------------------------------------------------------------------------- 1 | <%= render :partial => 'items/paginator' if @page_number > 1 %> 2 | 3 | <% last_date = nil %> 4 | <% @items.each do |item| %> 5 |
6 | <% unless last_date && last_date.day == item.created_at.day && last_date.month == item.created_at.month && last_date.year == item.created_at.year %> 7 |
<%= item.created_at.strftime("%B %d, %Y") %>
8 | <% last_date = item.created_at %> 9 | <% end %> 10 | <%= render :partial => 'item', :locals => { :item => item } -%> 11 |
12 | <% end %> 13 | <%= render :partial => 'items/paginator' %> 14 | -------------------------------------------------------------------------------- /app/views/items/index.rss.builder: -------------------------------------------------------------------------------- 1 | xml.instruct! :xml, :version=>"1.0" 2 | xml.rss(:version=>"2.0"){ 3 | xml.channel{ 4 | xml.title(APP_CONFIG[:app_title]) 5 | xml.link(APP_CONFIG[:app_url]) 6 | xml.description(APP_CONFIG[:sub_title]) 7 | xml.language('en-us') 8 | 9 | for item in @items.first(10) 10 | next unless item.user_id 11 | next unless item.user.approved_for_feed == 1 12 | xml.item do 13 | xml.title(item.title) 14 | xml.description(item.content) 15 | xml.pubDate(item.created_at.strftime("%a, %d %b %Y %H:%M:%S %z")) 16 | xml.link(APP_CONFIG[:app_url] + "items/" + item.id.to_s) 17 | xml.guid(APP_CONFIG[:app_url] + "items/" + item.id.to_s) 18 | end 19 | end 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/views/items/list_for_tags.html.erb: -------------------------------------------------------------------------------- 1 |

<%= @tag_array.collect { |a| link_to a, tag_url(a) }.join(' & ') %>

2 | 3 | <% @items.each do |item| %> 4 | <%= render :partial => 'item', :locals => { :item => item } -%> 5 | <% end %> 6 | 7 |
8 | 9 | <%= link_to 'New item', new_item_path %> 10 | -------------------------------------------------------------------------------- /app/views/items/new.html.erb: -------------------------------------------------------------------------------- 1 |

Post An Item to the Flow

2 | 3 | <%= render :partial => 'edit_item', :locals => { :item => @item, :method => 'post'} %> -------------------------------------------------------------------------------- /app/views/items/recently.html.erb: -------------------------------------------------------------------------------- 1 | <%= render :partial => 'items/paginator' if @page_number > 1 %> 2 | 3 |

Recently in your Flow

4 | 5 | <% if @items.empty? %> 6 |

Nothings happened in your flow recently - try starring some more stories for more activity.

7 | <% else %> 8 |
9 | <% end %> 10 | 11 | <% @items.each do |item| %> 12 | <%= render :partial => 'item', :locals => { :item => item } -%> 13 |
14 |

This item has <%= pluralize item.comments.select { |c| c.created_at > @last_checked_at }.size, "new comment" -%> and <%= item.updated_at > @last_checked_at ? "has" : "hasn't" -%> been edited.

15 |
16 | <% end %> 17 | 18 | <%= render :partial => 'items/paginator' %> 19 | -------------------------------------------------------------------------------- /app/views/items/search.html.erb: -------------------------------------------------------------------------------- 1 | 2 | <% @items.each do |item| %> 3 | <%= render :partial => 'item', :locals => { :item => item } -%> 4 | <% end %> 5 | 6 |
7 | 8 | <%= link_to 'New item', new_item_path %> 9 | -------------------------------------------------------------------------------- /app/views/items/show.html.erb: -------------------------------------------------------------------------------- 1 | <%= render :partial => @item %> 2 | 3 |
4 | 5 | <% unless @item.stars.blank? %> 6 |

Starred by:

7 |

<%= @item.stars.map { |star| link_to star.user.login, star.user.url }.to_sentence -%>

8 | <% end %> 9 | 10 |

<%= pluralize @item.comments.count, 'comment' %>

11 | <% @item.comments.each do |comment| %> 12 |
<%= safe(comment.content) %><%= comment.user ? %Q{#{comment.user.login}} : comment.byline %> - <%= comment.created_at.strftime("%B %d, %Y %R") %>
13 | <% end %> 14 | 15 | <%= render :partial => 'comments/edit_comment', :locals => {:comment => @comment, :item => @item} %> 16 |
-------------------------------------------------------------------------------- /app/views/layouts/categories.html.erb: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | Categories: <%= controller.action_name %> 8 | <%= stylesheet_link_tag 'scaffold' %> 9 | 10 | 11 | 12 |

<%= flash[:notice] %>

13 | 14 | <%= yield %> 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/views/layouts/comments.html.erb: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | Comments: <%= controller.action_name %> 8 | <%= stylesheet_link_tag 'scaffold' %> 9 | 10 | 11 | 12 |

<%= flash[:notice] %>

13 | 14 | <%= yield %> 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/views/layouts/items.html.erb: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | Items: <%= controller.action_name %> 8 | <%= stylesheet_link_tag 'scaffold' %> 9 | 10 | 11 | 12 |

<%= flash[:notice] %>

13 | 14 | <%= yield %> 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/views/layouts/main.html.erb: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | <%= title %> 7 | 8 | 9 | <% if @front_page %> 10 | <% end %> 11 | 12 | <% if @noindex %><% end -%> 13 | 14 | <%= stylesheet_link_tag "main" %> 15 | <%= javascript_include_tag :defaults, :cache => true if APP_CONFIG[:uses_javascript] %> 16 | 17 | 18 | 19 | 20 | 33 | 34 |
35 |
36 | <% if flash[:notice] %>

<%= flash[:notice] %>

<% end %> 37 | <%= yield %> 38 |
39 | 40 | 43 | 44 |
45 | 46 |
47 | <% if APP_CONFIG[:ga] %> 48 | 52 | 57 | <% end %> 58 | 59 | -------------------------------------------------------------------------------- /app/views/session/new.html.erb: -------------------------------------------------------------------------------- 1 |

Log In To The Flow

2 | 3 | <% form_tag session_path do -%> 4 |


5 | <%= text_field_tag 'login' %>

6 | 7 |

Note that logins are case sensitive. Use the same casing as displays on the site / you used at signup.

8 | 9 |


10 | <%= password_field_tag 'password' %>

11 | 12 |

13 | <%= check_box_tag 'remember_me' %>

14 | 15 |

16 | <%= submit_tag 'Log In' %> 17 | or 18 | <%= link_to 'Signup for a new account', signup_path, :title => 'It only takes about 15 seconds.' %> 19 |

20 | <% end -%> -------------------------------------------------------------------------------- /app/views/users/index.html.erb: -------------------------------------------------------------------------------- 1 | 4 | 5 | <% @users.each do |user| %> 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | <% end %> 15 |
  <%= user.id %>    <%= user.login %>    <%= user.url %>    <%= user.created_at.strftime("%b %d, %Y") %>    <%= user.approved_for_feed %>  <%= link_to 'approve', :action => 'approve', :id => user.id %> | <%= link_to 'disapprove', :action => 'disapprove', :id => user.id %> | <%= link_to 'delete', :action => 'destroy', :id => user.id, :method => :post %>
-------------------------------------------------------------------------------- /app/views/users/new.html.erb: -------------------------------------------------------------------------------- 1 |

Join The Flow!

2 | 3 | <%= error_messages_for :user %> 4 | 5 |

Sorry. Keeping it real bare bones for the moment, so no OpenID yet!

6 | 7 | <% form_for :user, :url => users_path do |f| -%> 8 |


9 | <%= f.text_field :login %>

10 | 11 |

Usernames are case sensitive, but you're welcome to use mixed case and underscores as necessary (e.g. BobSmith Fred_Turner bert1974)

12 | 13 |


14 | <%= f.text_field :url %>

15 | 16 |

Note that this URL is linked from your username in various places around the site.

17 | 18 |


19 | <%= f.password_field :password %>

20 | 21 |


22 | <%= f.password_field :password_confirmation %>

23 | 24 | <%= render :partial => 'home/signup_captcha' %> 25 | 26 |

<%= submit_tag 'Sign up' %>

27 | <% end -%> 28 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | # Don't change this file! 2 | # Configure your app in config/environment.rb and config/environments/*.rb 3 | 4 | RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) 5 | 6 | module Rails 7 | class << self 8 | def boot! 9 | unless booted? 10 | preinitialize 11 | pick_boot.run 12 | end 13 | end 14 | 15 | def booted? 16 | defined? Rails::Initializer 17 | end 18 | 19 | def pick_boot 20 | (vendor_rails? ? VendorBoot : GemBoot).new 21 | end 22 | 23 | def vendor_rails? 24 | File.exist?("#{RAILS_ROOT}/vendor/rails") 25 | end 26 | 27 | def preinitialize 28 | load(preinitializer_path) if File.exist?(preinitializer_path) 29 | end 30 | 31 | def preinitializer_path 32 | "#{RAILS_ROOT}/config/preinitializer.rb" 33 | end 34 | end 35 | 36 | class Boot 37 | def run 38 | load_initializer 39 | Rails::Initializer.run(:set_load_path) 40 | end 41 | end 42 | 43 | class VendorBoot < Boot 44 | def load_initializer 45 | require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" 46 | Rails::Initializer.run(:install_gem_spec_stubs) 47 | end 48 | end 49 | 50 | class GemBoot < Boot 51 | def load_initializer 52 | self.class.load_rubygems 53 | load_rails_gem 54 | require 'initializer' 55 | end 56 | 57 | def load_rails_gem 58 | if version = self.class.gem_version 59 | gem 'rails', version 60 | else 61 | gem 'rails' 62 | end 63 | rescue Gem::LoadError => load_error 64 | $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.) 65 | exit 1 66 | end 67 | 68 | class << self 69 | def rubygems_version 70 | Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion 71 | end 72 | 73 | def gem_version 74 | if defined? RAILS_GEM_VERSION 75 | RAILS_GEM_VERSION 76 | elsif ENV.include?('RAILS_GEM_VERSION') 77 | ENV['RAILS_GEM_VERSION'] 78 | else 79 | parse_gem_version(read_environment_rb) 80 | end 81 | end 82 | 83 | def load_rubygems 84 | require 'rubygems' 85 | 86 | unless rubygems_version >= '0.9.4' 87 | $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.) 88 | exit 1 89 | end 90 | 91 | rescue LoadError 92 | $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org) 93 | exit 1 94 | end 95 | 96 | def parse_gem_version(text) 97 | $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ 98 | end 99 | 100 | private 101 | def read_environment_rb 102 | File.read("#{RAILS_ROOT}/config/environment.rb") 103 | end 104 | end 105 | end 106 | end 107 | 108 | # All that for this: 109 | Rails.boot! 110 | -------------------------------------------------------------------------------- /config/database.yml.dist: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3-ruby (not necessary on OS X Leopard) 3 | development: 4 | adapter: sqlite3 5 | database: db/development.sqlite3 6 | timeout: 5000 7 | 8 | # Warning: The database defined as "test" will be erased and 9 | # re-generated from your development database when you run "rake". 10 | # Do not set this db to the same as development or production. 11 | test: 12 | adapter: sqlite3 13 | database: db/test.sqlite3 14 | timeout: 5000 15 | 16 | production: 17 | adapter: sqlite3 18 | database: db/production.sqlite3 19 | timeout: 5000 20 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | app_name = "rubyflow" 2 | 3 | # Be sure to restart your server when you modify this file 4 | 5 | # Uncomment below to force Rails into production mode when 6 | # you don't control web/app server and can't set it the proper way 7 | # ENV['RAILS_ENV'] ||= 'production' 8 | 9 | # Specifies gem version of Rails to use when vendor/rails is not present 10 | RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION 11 | 12 | # Bootstrap the Rails environment, frameworks, and default configuration 13 | require File.join(File.dirname(__FILE__), 'boot') 14 | 15 | 16 | Rails::Initializer.run do |config| 17 | # Settings in config/environments/* take precedence over those specified here. 18 | # Application configuration should go into files in config/initializers 19 | # -- all .rb files in that directory are automatically loaded. 20 | # See Rails::Configuration for more options. 21 | 22 | # Skip frameworks you're not going to use (only works if using vendor/rails). 23 | # To use Rails without a database, you must remove the Active Record framework 24 | # config.frameworks -= [ :active_record, :active_resource, :action_mailer ] 25 | 26 | # Only load the plugins named here, in the order given. By default, all plugins 27 | # in vendor/plugins are loaded in alphabetical order. 28 | # :all can be used as a placeholder for all plugins not explicitly named 29 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] 30 | 31 | # Add additional load paths for your own custom dirs 32 | # config.load_paths += %W( #{RAILS_ROOT}/extras ) 33 | 34 | # Force all environments to use the same logger level 35 | # (by default production uses :info, the others :debug) 36 | # config.log_level = :debug 37 | 38 | # Your secret key for verifying cookie session data integrity. 39 | # If you change this key, all old sessions will become invalid! 40 | # Make sure the secret is at least 30 characters and all random, 41 | # no regular words or you'll be exposed to dictionary attacks. 42 | config.action_controller.session = { 43 | :session_key => "_#{app_name}_session", 44 | :secret => 'youneedtochangethistosomethingelsethankyouverymuch' 45 | } 46 | 47 | # Use the database for sessions instead of the cookie-based default, 48 | # which shouldn't be used to store highly confidential information 49 | # (create the session table with 'rake db:sessions:create') 50 | # config.action_controller.session_store = :active_record_store 51 | 52 | # Use SQL instead of Active Record's schema dumper when creating the test database. 53 | # This is necessary if your schema can't be completely dumped by the schema dumper, 54 | # like if you have constraints or database-specific column types 55 | # config.active_record.schema_format = :sql 56 | 57 | # Activate observers that should always be running 58 | # config.active_record.observers = :cacher, :garbage_collector 59 | 60 | # Make Active Record use UTC-base instead of local time 61 | # config.active_record.default_timezone = :utc 62 | config.gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => 'http://gems.github.com' 63 | end 64 | 65 | APP_CONFIG = YAML::load(File.open("#{RAILS_ROOT}/config/#{app_name}.yml")).symbolize_keys -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | # Settings specified here will take precedence over those in config/environment.rb 2 | 3 | # In the development environment your application's code is reloaded on 4 | # every request. This slows down response time but is perfect for development 5 | # since you don't have to restart the webserver when you make code changes. 6 | config.cache_classes = false 7 | 8 | # Log error messages when you accidentally call methods on nil. 9 | config.whiny_nils = true 10 | 11 | # Show full error reports and disable caching 12 | config.action_controller.consider_all_requests_local = true 13 | config.action_view.debug_rjs = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send 17 | config.action_mailer.raise_delivery_errors = false -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | # Settings specified here will take precedence over those in config/environment.rb 2 | 3 | # The production environment is meant for finished, "live" apps. 4 | # Code is not reloaded between requests 5 | config.cache_classes = true 6 | 7 | # Use a different logger for distributed setups 8 | # config.logger = SyslogLogger.new 9 | 10 | # Full error reports are disabled and caching is turned on 11 | config.action_controller.consider_all_requests_local = false 12 | config.action_controller.perform_caching = true 13 | config.action_view.cache_template_loading = true 14 | 15 | # Enable serving of images, stylesheets, and javascripts from an asset server 16 | # config.action_controller.asset_host = "http://assets.example.com" 17 | 18 | # Disable delivery errors, bad email addresses will be ignored 19 | # config.action_mailer.raise_delivery_errors = false 20 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | # Settings specified here will take precedence over those in config/environment.rb 2 | 3 | # The test environment is used exclusively to run your application's 4 | # test suite. You never need to work with it otherwise. Remember that 5 | # your test database is "scratch space" for the test suite and is wiped 6 | # and recreated between test runs. Don't rely on the data there! 7 | config.cache_classes = true 8 | 9 | # Log error messages when you accidentally call methods on nil. 10 | config.whiny_nils = true 11 | 12 | # Show full error reports and disable caching 13 | config.action_controller.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Disable request forgery protection in test environment 17 | config.action_controller.allow_forgery_protection = false 18 | 19 | # Tell ActionMailer not to deliver emails to the real world. 20 | # The :test delivery method accumulates sent emails in the 21 | # ActionMailer::Base.deliveries array. 22 | config.action_mailer.delivery_method = :test 23 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format 4 | # (all these examples are active by default): 5 | # Inflector.inflections do |inflect| 6 | # inflect.plural /^(ox)$/i, '\1en' 7 | # inflect.singular /^(ox)en/i, '\1' 8 | # inflect.irregular 'person', 'people' 9 | # inflect.uncountable %w( fish sheep ) 10 | # end 11 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | # Mime::Type.register_alias "text/html", :iphone 6 | -------------------------------------------------------------------------------- /config/pythonflow.yml: -------------------------------------------------------------------------------- 1 | app_name: pythonflow 2 | app_title: PythonFlow 3 | default_title: "PythonFlow : Python Community Link Blog" 4 | sub_title: "Community-maintained Python News and Links" 5 | app_url: http://www.pythonflow.com/ 6 | rss_url: http://feeds.feedburner.com/Pythonflow 7 | meta_keywords: "python, python news, python blog, django" 8 | meta_author: "Peter Cooper" 9 | body_class: pythonflow 10 | 11 | # Set this to true for a more fancy interface, but for the cost of page load time 12 | uses_javascript: false 13 | 14 | # Edit expiration default: 60 (this means that editing ends 60 minutes after last update of item) 15 | # Set to 0 or omit to always allow editing of items by its owner 16 | edit_expiration_in_minutes: 60 17 | 18 | ga: UA-2237791-8 19 | sidebar: |- 20 |

What?

PythonFlow is an experimental community driven Python links site. Items are not added automatically, but chosen and summarized by community members, resulting in a better quality and context than social bookmarking sites can offer.

21 |

How?

Enjoy the links, comment or make a post of your own. You don't need to be signed in!

22 |

Note: If you're not signed in, your byline is unlinked and your links are made "nofollow" to prevent spam. You also get CAPTCHAed!

23 |

Yes, this site is influenced by MetaFilter. Matt Haughey is one of my heroes.

-------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | ActionController::Routing::Routes.draw do |map| 2 | map.root :controller => 'items' 3 | 4 | map.resources :items, :collection => {:recently => :get} do |items| 5 | items.resources :comments 6 | items.add_star '/star/add', :controller => "stars", :action => "add" 7 | items.remove_star '/star/remove', :controller => "stars", :action => "remove" 8 | end 9 | 10 | map.resources :categories 11 | 12 | map.resources :users 13 | map.resource :session, :controller => 'session' 14 | 15 | 16 | map.signup '/signup', :controller => 'users', :action => 'new' 17 | map.login '/login', :controller => 'session', :action => 'new' 18 | map.logout '/logout', :controller => 'session', :action => 'destroy' 19 | 20 | map.tag '/tag/:id', :controller => 'items', :action => 'list_for_tags' 21 | map.tags '/tags/:id', :controller => 'items', :action => 'list_for_tags' 22 | map.tags_by_folders '/tags/*id', :controller => 'items', :action => 'list_for_tags' 23 | map.search '/search/:id', :controller => 'items', :action => 'search' 24 | map.category '/category/:id', :controller => 'items', :action => 'category' 25 | 26 | map.connect '/page/:page', :controller => 'items', :action => 'index' 27 | 28 | # Install the default routes as the lowest priority. 29 | map.connect ':controller/:action/:id' 30 | map.connect ':controller/:action/:id.:format' 31 | end 32 | -------------------------------------------------------------------------------- /config/rubyflow.yml: -------------------------------------------------------------------------------- 1 | app_name: rubyflow 2 | app_title: RubyFlow 3 | default_title: "RubyFlow : Community Filtered Ruby News" 4 | sub_title: "Community-maintained Ruby News" 5 | app_url: http://www.rubyflow.com/ 6 | rss_url: http://feeds.feedburner.com/Rubyflow 7 | meta_keywords: "ruby, ruby news, ruby blog, rails, rubyonrails" 8 | meta_author: "Peter Cooper" 9 | body_class: rubyflow 10 | 11 | # Set this to true for a more fancy interface, but for the cost of page load time 12 | uses_javascript: false 13 | 14 | # Edit expiration default: 60 (this means that editing ends 60 minutes after last update of item) 15 | # Set to 0 or omit to always allow editing of items by its owner 16 | edit_expiration_in_minutes: 60 17 | 18 | # ga: UA-2237791-7 19 | sidebar: |- 20 |

What?

RubyFlow is a community driven Ruby links site. Items are not added automatically, but chosen and summarized by the community, resulting in a higher quality of links than social bookmarking sites.

21 |

Japanese / Nihongo?

There is a Japanese version of RubyFlow available, thanks to Makoto Kuwata!

22 |

How?

Enjoy the links, comment or make a post of your own. You don't need to be signed in!

23 |

Note: If you're not signed in, your byline is unlinked and your links are made "nofollow" to prevent spam. You also get CAPTCHAed!

24 |

Who?

RubyFlow was built by Peter Cooper of Ruby Inside, but is ultimately a community site.

25 |

Yes, this site is influenced by MetaFilter. I wrote a popular MetaFilter clone back in the day so it's okay!

26 |

-------------------------------------------------------------------------------- /db/migrate/001_create_users.rb: -------------------------------------------------------------------------------- 1 | class CreateUsers < ActiveRecord::Migration 2 | def self.up 3 | create_table "users", :force => true do |t| 4 | t.column :login, :string 5 | t.column :email, :string 6 | t.column :fullname, :string 7 | t.column :url, :string 8 | t.column :crypted_password, :string, :limit => 40 9 | t.column :salt, :string, :limit => 40 10 | t.column :created_at, :datetime 11 | t.column :updated_at, :datetime 12 | t.column :remember_token, :string 13 | t.column :remember_token_expires_at, :datetime 14 | 15 | 16 | end 17 | end 18 | 19 | def self.down 20 | drop_table "users" 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /db/migrate/002_add_admin_flag_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddAdminFlagToUsers < ActiveRecord::Migration 2 | def self.up 3 | add_column :users, :admin, :integer, :default => 0 4 | end 5 | 6 | def self.down 7 | remove_column :users, :admin 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/003_add_open_id_authentication_tables.rb: -------------------------------------------------------------------------------- 1 | class AddOpenIdAuthenticationTables < ActiveRecord::Migration 2 | def self.up 3 | create_table "open_id_authentication_associations", :force => true do |t| 4 | t.column "server_url", :binary 5 | t.column "handle", :string 6 | t.column "secret", :binary 7 | t.column "issued", :integer 8 | t.column "lifetime", :integer 9 | t.column "assoc_type", :string 10 | end 11 | 12 | create_table "open_id_authentication_nonces", :force => true do |t| 13 | t.column "nonce", :string 14 | t.column "created", :integer 15 | end 16 | 17 | create_table "open_id_authentication_settings", :force => true do |t| 18 | t.column "setting", :string 19 | t.column "value", :binary 20 | end 21 | 22 | add_column :users, :identity_url, :string 23 | end 24 | 25 | def self.down 26 | remove_column :users, :identity_url 27 | drop_table "open_id_authentication_associations" 28 | drop_table "open_id_authentication_nonces" 29 | drop_table "open_id_authentication_settings" 30 | end 31 | end -------------------------------------------------------------------------------- /db/migrate/004_create_items.rb: -------------------------------------------------------------------------------- 1 | class CreateItems < ActiveRecord::Migration 2 | def self.up 3 | create_table :items do |t| 4 | t.string :title 5 | t.string :url 6 | t.text :content 7 | t.text :metadata 8 | t.string :name 9 | t.string :tags 10 | t.references :user 11 | 12 | t.timestamps 13 | end 14 | end 15 | 16 | def self.down 17 | drop_table :items 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /db/migrate/005_change_tags_to_text_on_items.rb: -------------------------------------------------------------------------------- 1 | class ChangeTagsToTextOnItems < ActiveRecord::Migration 2 | def self.up 3 | change_column :items, :tags, :text 4 | end 5 | 6 | def self.down 7 | change_column :items, :tags, :string 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/006_create_categories.rb: -------------------------------------------------------------------------------- 1 | class CreateCategories < ActiveRecord::Migration 2 | def self.up 3 | create_table :categories do |t| 4 | t.string :name 5 | t.string :title 6 | t.references :parent 7 | t.string :query 8 | 9 | t.timestamps 10 | end 11 | end 12 | 13 | def self.down 14 | drop_table :categories 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /db/migrate/007_create_comments.rb: -------------------------------------------------------------------------------- 1 | class CreateComments < ActiveRecord::Migration 2 | def self.up 3 | create_table :comments do |t| 4 | t.text :content 5 | t.string :byline 6 | t.references :user 7 | t.references :item 8 | 9 | t.timestamps 10 | end 11 | end 12 | 13 | def self.down 14 | drop_table :comments 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /db/migrate/008_add_byline_to_item.rb: -------------------------------------------------------------------------------- 1 | class AddBylineToItem < ActiveRecord::Migration 2 | def self.up 3 | add_column :items, :byline, :string 4 | end 5 | 6 | def self.down 7 | remove_column :items, :byline 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/009_add_comments_count_to_items.rb: -------------------------------------------------------------------------------- 1 | class AddCommentsCountToItems < ActiveRecord::Migration 2 | def self.up 3 | add_column :items, :comments_count, :integer, :default => 0 4 | end 5 | 6 | def self.down 7 | remove_column :items, :comments_count 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/010_user_approved_for_feed.rb: -------------------------------------------------------------------------------- 1 | class UserApprovedForFeed < ActiveRecord::Migration 2 | def self.up 3 | add_column :users, :approved_for_feed, :integer, :default => 0 4 | end 5 | 6 | def self.down 7 | remove_column :users, :approved_for_feed 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/011_create_stars.rb: -------------------------------------------------------------------------------- 1 | class CreateStars < ActiveRecord::Migration 2 | def self.up 3 | create_table :stars, :id => false do |t| 4 | t.integer :item_id 5 | t.integer :user_id 6 | end 7 | end 8 | 9 | def self.down 10 | drop_table :stars 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/012_add_counter_cache_for_stars.rb: -------------------------------------------------------------------------------- 1 | class AddCounterCacheForStars < ActiveRecord::Migration 2 | def self.up 3 | add_column :items, :stars_count, :integer, :default => 0 4 | end 5 | 6 | def self.down 7 | remove_column :stars_count 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/013_add_id_to_stars.rb: -------------------------------------------------------------------------------- 1 | class AddIdToStars < ActiveRecord::Migration 2 | def self.up 3 | add_column :stars, :id, :integer, :primary_key => true 4 | end 5 | 6 | def self.down 7 | remove_column :stars, :id 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/014_recreate_stars_table.rb: -------------------------------------------------------------------------------- 1 | class RecreateStarsTable < ActiveRecord::Migration 2 | def self.up 3 | drop_table(:stars) 4 | create_table :stars do |t| 5 | t.integer :user_id 6 | t.integer :item_id 7 | end 8 | end 9 | 10 | def self.down 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /db/migrate/015_add_last_checked_at_to_user.rb: -------------------------------------------------------------------------------- 1 | class AddLastCheckedAtToUser < ActiveRecord::Migration 2 | def self.up 3 | add_column :users, :last_checked_at, :datetime 4 | end 5 | 6 | def self.down 7 | remove_column :users, :last_checked_at 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead of editing this file, 2 | # please use the migrations feature of Active Record to incrementally modify your database, and 3 | # then regenerate this schema definition. 4 | # 5 | # Note that this schema.rb definition is the authoritative source for your database schema. If you need 6 | # to create the application database on another system, you should be using db:schema:load, not running 7 | # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations 8 | # you'll amass, the slower it'll run and the greater likelihood for issues). 9 | # 10 | # It's strongly recommended to check this file into your version control system. 11 | 12 | ActiveRecord::Schema.define(:version => 17) do 13 | 14 | create_table "categories", :force => true do |t| 15 | t.string "name" 16 | t.string "title" 17 | t.integer "parent_id" 18 | t.string "query" 19 | t.datetime "created_at" 20 | t.datetime "updated_at" 21 | end 22 | 23 | create_table "comments", :force => true do |t| 24 | t.text "content" 25 | t.string "byline" 26 | t.integer "user_id" 27 | t.integer "item_id" 28 | t.datetime "created_at" 29 | t.datetime "updated_at" 30 | end 31 | 32 | create_table "items", :force => true do |t| 33 | t.string "title" 34 | t.string "url" 35 | t.text "content" 36 | t.text "metadata" 37 | t.string "name" 38 | t.text "tags", :limit => 255 39 | t.integer "user_id" 40 | t.datetime "created_at" 41 | t.datetime "updated_at" 42 | t.string "byline" 43 | t.integer "comments_count", :default => 0 44 | t.integer "stars_count", :default => 0 45 | t.integer "spam_reports_count", :default => 0 46 | end 47 | 48 | create_table "open_id_authentication_associations", :force => true do |t| 49 | t.binary "server_url" 50 | t.string "handle" 51 | t.binary "secret" 52 | t.integer "issued" 53 | t.integer "lifetime" 54 | t.string "assoc_type" 55 | end 56 | 57 | create_table "open_id_authentication_nonces", :force => true do |t| 58 | t.string "nonce" 59 | t.integer "created" 60 | end 61 | 62 | create_table "open_id_authentication_settings", :force => true do |t| 63 | t.string "setting" 64 | t.binary "value" 65 | end 66 | 67 | create_table "spam_reports", :force => true do |t| 68 | t.integer "item_id" 69 | t.integer "user_id" 70 | t.datetime "created_at" 71 | t.datetime "updated_at" 72 | end 73 | 74 | create_table "stars", :force => true do |t| 75 | t.integer "user_id" 76 | t.integer "item_id" 77 | end 78 | 79 | create_table "users", :force => true do |t| 80 | t.string "login" 81 | t.string "email" 82 | t.string "fullname" 83 | t.string "url" 84 | t.string "crypted_password", :limit => 40 85 | t.string "salt", :limit => 40 86 | t.datetime "created_at" 87 | t.datetime "updated_at" 88 | t.string "remember_token" 89 | t.datetime "remember_token_expires_at" 90 | t.integer "admin", :default => 0 91 | t.string "identity_url" 92 | t.integer "approved_for_feed", :default => 0 93 | t.datetime "last_checked_at" 94 | end 95 | 96 | end 97 | -------------------------------------------------------------------------------- /lib/authenticated_test_helper.rb: -------------------------------------------------------------------------------- 1 | module AuthenticatedTestHelper 2 | # Sets the current user in the session from the user fixtures. 3 | def login_as(user) 4 | @request.session[:user_id] = user ? users(user).id : nil 5 | end 6 | 7 | def authorize_as(user) 8 | @request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentication::Basic.encode_credentials(users(user).login, 'test') : nil 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /log/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/log/.gitignore -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | # General Apache options 2 | AddHandler fastcgi-script .fcgi 3 | AddHandler cgi-script .cgi 4 | Options +FollowSymLinks +ExecCGI 5 | 6 | # If you don't want Rails to look in certain directories, 7 | # use the following rewrite rules so that Apache won't rewrite certain requests 8 | # 9 | # Example: 10 | # RewriteCond %{REQUEST_URI} ^/notrails.* 11 | # RewriteRule .* - [L] 12 | 13 | # Redirect all requests not available on the filesystem to Rails 14 | # By default the cgi dispatcher is used which is very slow 15 | # 16 | # For better performance replace the dispatcher with the fastcgi one 17 | # 18 | # Example: 19 | # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] 20 | RewriteEngine On 21 | 22 | # If your Rails application is accessed via an Alias directive, 23 | # then you MUST also set the RewriteBase in this htaccess file. 24 | # 25 | # Example: 26 | # Alias /myrailsapp /path/to/myrailsapp/public 27 | # RewriteBase /myrailsapp 28 | 29 | RewriteRule ^$ index.html [QSA] 30 | RewriteRule ^([^.]+)$ $1.html [QSA] 31 | RewriteCond %{REQUEST_FILENAME} !-f 32 | RewriteRule ^(.*)$ dispatch.cgi [QSA,L] 33 | 34 | # In case Rails experiences terminal errors 35 | # Instead of displaying this message you can supply a file here which will be rendered instead 36 | # 37 | # Example: 38 | # ErrorDocument 500 /500.html 39 | 40 | ErrorDocument 500 "

Application error

Rails application failed to start properly" 41 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | The page you were looking for doesn't exist (404) 9 | 21 | 22 | 23 | 24 | 25 |
26 |

The page you were looking for doesn't exist.

27 |

You may have mistyped the address or the page may have moved.

28 |
29 | 30 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | The change you wanted was rejected (422) 9 | 21 | 22 | 23 | 24 | 25 |
26 |

The change you wanted was rejected.

27 |

Maybe you tried to change something you didn't have access to.

28 |
29 | 30 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | We're sorry, but something went wrong (500) 9 | 21 | 22 | 23 | 24 | 25 |
26 |

We're sorry, but something went wrong.

27 |

We've been notified about this issue and we'll take a look at it shortly.

28 |
29 | 30 | -------------------------------------------------------------------------------- /public/dispatch.cgi: -------------------------------------------------------------------------------- 1 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 2 | 3 | require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) 4 | 5 | # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: 6 | # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired 7 | require "dispatcher" 8 | 9 | ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) 10 | Dispatcher.dispatch -------------------------------------------------------------------------------- /public/dispatch.fcgi: -------------------------------------------------------------------------------- 1 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 2 | # 3 | # You may specify the path to the FastCGI crash log (a log of unhandled 4 | # exceptions which forced the FastCGI instance to exit, great for debugging) 5 | # and the number of requests to process before running garbage collection. 6 | # 7 | # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log 8 | # and the GC period is nil (turned off). A reasonable number of requests 9 | # could range from 10-100 depending on the memory footprint of your app. 10 | # 11 | # Example: 12 | # # Default log path, normal GC behavior. 13 | # RailsFCGIHandler.process! 14 | # 15 | # # Default log path, 50 requests between GC. 16 | # RailsFCGIHandler.process! nil, 50 17 | # 18 | # # Custom log path, normal GC behavior. 19 | # RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log' 20 | # 21 | require File.dirname(__FILE__) + "/../config/environment" 22 | require 'fcgi_handler' 23 | 24 | RailsFCGIHandler.process! 25 | -------------------------------------------------------------------------------- /public/dispatch.rb: -------------------------------------------------------------------------------- 1 | #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 2 | 3 | require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) 4 | 5 | # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: 6 | # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired 7 | require "dispatcher" 8 | 9 | ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) 10 | Dispatcher.dispatch -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/public/favicon.ico -------------------------------------------------------------------------------- /public/images/rails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/public/images/rails.png -------------------------------------------------------------------------------- /public/javascripts/application.js: -------------------------------------------------------------------------------- 1 | var id_pattern = /item_wrapper_for_(\d+)/i; 2 | 3 | function star(item_id, is_starred) { 4 | if(is_starred) { 5 | var url = "/items/" + item_id + "/star/remove"; 6 | var jsOptions = "false"; 7 | } else { 8 | var url = "/items/" + item_id + "/star/add" 9 | var jsOptions = "true"; 10 | } 11 | 12 | // Send the data to the server 13 | 14 | $.get(url, {}, function(data) { 15 | $("#item_wrapper_for_" + item_id + " .star a").toggleClass("starred").html((jsOptions == "false" ? "" : "un") + "star this post"); 16 | $("#item_" + item_id + "-star-count").html(data); 17 | }, "text"); 18 | 19 | } 20 | 21 | function setupAdminAreaToggles() { 22 | $(".admin-actions").each(function(){ 23 | var current = $(this); 24 | var parent = current.parent(); 25 | parent.mouseover(function() { 26 | current.show(); 27 | }); 28 | parent.mouseout(function() { 29 | current.hide(); 30 | }); 31 | }).hide(); 32 | } 33 | 34 | // Someone might want to refactor / rewrite this to make it nicer. 35 | function setupItemAjaxSubmit() { 36 | var posts = $(".post"); 37 | posts.each(function() { 38 | var post = $(this); 39 | setStarFor(post); 40 | }); 41 | } 42 | 43 | function setStarFor(post) { 44 | var match = id_pattern.exec(post.attr("id")); 45 | // Check if we can extract the id. 46 | if(match != null) { 47 | var item_id = parseInt(match[1], 10); 48 | var star_link = post.find(".star a"); 49 | star_link.click(function(){ 50 | star(item_id, !(star_link.html().match(/un/) == null)); 51 | return false; 52 | }); 53 | } 54 | } 55 | 56 | // Set jQuery to automatically use the correct 57 | // accepts header so that we can use respond_to 58 | // with js. 59 | jQuery.ajaxSetup({ 60 | 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", 61 | "text/javascript")} 62 | }) 63 | 64 | 65 | // Make all JS behaviour unobtrusive. 66 | $(function() { 67 | setupAdminAreaToggles(); 68 | setupItemAjaxSubmit(); 69 | }); -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-Agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /public/stylesheets/scaffold.css: -------------------------------------------------------------------------------- 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 | 55 | div.uploadStatus { 56 | margin: 5px; 57 | } 58 | 59 | div.progressBar { 60 | margin: 5px; 61 | } 62 | 63 | div.progressBar div.border { 64 | background-color: #fff; 65 | border: 1px solid gray; 66 | width: 100%; 67 | } 68 | 69 | div.progressBar div.background { 70 | background-color: #333; 71 | height: 18px; 72 | width: 0%; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /script/about: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../config/boot' 3 | require 'commands/about' 4 | -------------------------------------------------------------------------------- /script/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../config/boot' 3 | require 'commands/console' 4 | -------------------------------------------------------------------------------- /script/dbconsole: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../config/boot' 3 | require 'commands/dbconsole' 4 | -------------------------------------------------------------------------------- /script/destroy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../config/boot' 3 | require 'commands/destroy' 4 | -------------------------------------------------------------------------------- /script/generate: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../config/boot' 3 | require 'commands/generate' 4 | -------------------------------------------------------------------------------- /script/performance/benchmarker: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../../config/boot' 3 | require 'commands/performance/benchmarker' 4 | -------------------------------------------------------------------------------- /script/performance/profiler: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../../config/boot' 3 | require 'commands/performance/profiler' 4 | -------------------------------------------------------------------------------- /script/performance/request: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../../config/boot' 3 | require 'commands/performance/request' 4 | -------------------------------------------------------------------------------- /script/plugin: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../config/boot' 3 | require 'commands/plugin' 4 | -------------------------------------------------------------------------------- /script/process/inspector: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../../config/boot' 3 | require 'commands/process/inspector' 4 | -------------------------------------------------------------------------------- /script/process/reaper: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../../config/boot' 3 | require 'commands/process/reaper' 4 | -------------------------------------------------------------------------------- /script/process/spawner: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../../config/boot' 3 | require 'commands/process/spawner' 4 | -------------------------------------------------------------------------------- /script/runner: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../config/boot' 3 | require 'commands/runner' 4 | -------------------------------------------------------------------------------- /script/server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../config/boot' 3 | require 'commands/server' 4 | -------------------------------------------------------------------------------- /test/factories/item_factory.rb: -------------------------------------------------------------------------------- 1 | Factory.define :item do |item| 2 | item.title { Factory.next :title } 3 | item.name { Factory.next :name } 4 | item.content 'content' * 5 5 | end -------------------------------------------------------------------------------- /test/factories/misc_sequences.rb: -------------------------------------------------------------------------------- 1 | Factory.sequence :title do |n| 2 | "Some Title #{n}" 3 | end 4 | 5 | Factory.sequence :name do |n| 6 | "name-#{n}" 7 | end 8 | 9 | Factory.sequence :login do |n| 10 | "login#{n}" 11 | end -------------------------------------------------------------------------------- /test/factories/user_factory.rb: -------------------------------------------------------------------------------- 1 | Factory.define :user do |u| 2 | u.login { Factory.next :login } 3 | u.password 'sekrit' 4 | u.password_confirmation 'sekrit' 5 | end -------------------------------------------------------------------------------- /test/fixtures/categories.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html 2 | 3 | one: 4 | name: MyString 5 | title: MyString 6 | parent: 7 | query: MyString 8 | 9 | two: 10 | name: MyString 11 | title: MyString 12 | parent: 13 | query: MyString 14 | -------------------------------------------------------------------------------- /test/fixtures/comments.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html 2 | 3 | one: 4 | content: MyText 5 | byline: MyString 6 | user: 7 | 8 | two: 9 | content: MyText 10 | byline: MyString 11 | user: 12 | -------------------------------------------------------------------------------- /test/fixtures/items.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html 2 | 3 | one: 4 | title: MyString 5 | url: MyString 6 | content: MyText 7 | metadata: MyText 8 | name: MyString1 9 | tags: MyString 10 | user_id: 1 11 | 12 | two: 13 | title: MyString 14 | url: MyString 15 | content: MyText 16 | metadata: MyText 17 | name: MyString2 18 | tags: MyString 19 | user_id: 1 20 | -------------------------------------------------------------------------------- /test/fixtures/stars.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html 2 | 3 | one: 4 | item_id: 1 5 | user_id: 1 6 | 7 | two: 8 | item_id: 1 9 | user_id: 1 10 | -------------------------------------------------------------------------------- /test/fixtures/users.yml: -------------------------------------------------------------------------------- 1 | quentin: 2 | id: 1 3 | login: quentin 4 | email: quentin@example.com 5 | salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd 6 | crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test 7 | created_at: <%= 5.days.ago.to_s :db %> 8 | 9 | 10 | 11 | aaron: 12 | id: 2 13 | login: aaron 14 | email: aaron@example.com 15 | salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd 16 | crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test 17 | created_at: <%= 1.days.ago.to_s :db %> 18 | 19 | 20 | -------------------------------------------------------------------------------- /test/functional/comments_controller_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class CommentsControllerTest < ActionController::TestCase 4 | def test_should_get_index 5 | get :index 6 | assert_response :success 7 | assert_not_nil assigns(:comments) 8 | end 9 | 10 | def test_should_get_new 11 | get :new 12 | assert_response :success 13 | end 14 | 15 | def test_should_create_comment 16 | assert_difference('Comment.count') do 17 | post :create, :comment => { } 18 | end 19 | 20 | assert_redirected_to comment_path(assigns(:comment)) 21 | end 22 | 23 | def test_should_show_comment 24 | get :show, :id => comments(:one).id 25 | assert_response :success 26 | end 27 | 28 | def test_should_get_edit 29 | get :edit, :id => comments(:one).id 30 | assert_response :success 31 | end 32 | 33 | def test_should_update_comment 34 | put :update, :id => comments(:one).id, :comment => { } 35 | assert_redirected_to comment_path(assigns(:comment)) 36 | end 37 | 38 | def test_should_destroy_comment 39 | assert_difference('Comment.count', -1) do 40 | delete :destroy, :id => comments(:one).id 41 | end 42 | 43 | assert_redirected_to comments_path 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /test/functional/home_controller_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class HomeControllerTest < ActionController::TestCase 4 | # Replace this with your real tests. 5 | def test_truth 6 | assert true 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /test/functional/items_controller_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class ItemsControllerTest < ActionController::TestCase 4 | def test_should_get_index 5 | get :index 6 | assert_response :success 7 | assert_not_nil assigns(:items) 8 | end 9 | 10 | def test_shouldnt_get_new 11 | get :new 12 | assert_response :redirect 13 | end 14 | 15 | def test_shouldnt_create_item 16 | assert_no_difference('Item.count') do 17 | post :create, :item => { } 18 | end 19 | end 20 | 21 | def test_should_show_item 22 | get :show, :id => items(:one).id 23 | assert_response :success 24 | end 25 | 26 | def test_shouldnt_get_edit 27 | get :edit, :id => items(:one).id 28 | assert_response :redirect 29 | end 30 | 31 | def test_shouldnt_update_item 32 | put :update, :id => items(:one).id, :item => { } 33 | assert_response :redirect 34 | end 35 | 36 | def test_shouldnt_destroy_item 37 | assert_no_difference('Item.count') do 38 | delete :destroy, :id => items(:one).id 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /test/functional/session_controller_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | require 'session_controller' 3 | 4 | # Re-raise errors caught by the controller. 5 | class SessionController; def rescue_action(e) raise e end; end 6 | 7 | class SessionControllerTest < Test::Unit::TestCase 8 | # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead 9 | # Then, you can remove it from this and the units test. 10 | include AuthenticatedTestHelper 11 | 12 | fixtures :users 13 | 14 | def setup 15 | @controller = SessionController.new 16 | @request = ActionController::TestRequest.new 17 | @response = ActionController::TestResponse.new 18 | end 19 | 20 | def test_should_login_and_redirect 21 | post :create, :login => 'quentin', :password => 'test' 22 | assert session[:user_id] 23 | assert_response :redirect 24 | end 25 | 26 | def test_should_fail_login_and_not_redirect 27 | post :create, :login => 'quentin', :password => 'bad password' 28 | assert_nil session[:user_id] 29 | assert_response :success 30 | end 31 | 32 | def test_should_logout 33 | login_as :quentin 34 | get :destroy 35 | assert_nil session[:user_id] 36 | assert_response :redirect 37 | end 38 | 39 | def test_should_remember_me 40 | post :create, :login => 'quentin', :password => 'test', :remember_me => "1" 41 | assert_not_nil @response.cookies["auth_token"] 42 | end 43 | 44 | def test_should_not_remember_me 45 | post :create, :login => 'quentin', :password => 'test', :remember_me => "0" 46 | assert_nil @response.cookies["auth_token"] 47 | end 48 | 49 | def test_should_delete_token_on_logout 50 | login_as :quentin 51 | get :destroy 52 | assert_equal @response.cookies["auth_token"], [] 53 | end 54 | 55 | def test_should_login_with_cookie 56 | users(:quentin).remember_me 57 | @request.cookies["auth_token"] = cookie_for(:quentin) 58 | get :new 59 | assert @controller.send(:logged_in?) 60 | end 61 | 62 | def test_should_fail_expired_cookie_login 63 | users(:quentin).remember_me 64 | users(:quentin).update_attribute :remember_token_expires_at, 5.minutes.ago 65 | @request.cookies["auth_token"] = cookie_for(:quentin) 66 | get :new 67 | assert !@controller.send(:logged_in?) 68 | end 69 | 70 | def test_should_fail_cookie_login 71 | users(:quentin).remember_me 72 | @request.cookies["auth_token"] = auth_token('invalid_auth_token') 73 | get :new 74 | assert !@controller.send(:logged_in?) 75 | end 76 | 77 | protected 78 | def auth_token(token) 79 | CGI::Cookie.new('name' => 'auth_token', 'value' => token) 80 | end 81 | 82 | def cookie_for(user) 83 | auth_token users(user).remember_token 84 | end 85 | end 86 | -------------------------------------------------------------------------------- /test/functional/users_controller_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | require 'users_controller' 3 | 4 | # Re-raise errors caught by the controller. 5 | class UsersController; def rescue_action(e) raise e end; end 6 | 7 | class UsersControllerTest < Test::Unit::TestCase 8 | # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead 9 | # Then, you can remove it from this and the units test. 10 | include AuthenticatedTestHelper 11 | 12 | fixtures :users 13 | 14 | def setup 15 | @controller = UsersController.new 16 | @request = ActionController::TestRequest.new 17 | @response = ActionController::TestResponse.new 18 | end 19 | 20 | def test_should_allow_signup 21 | assert_difference 'User.count' do 22 | create_user 23 | assert_response :redirect 24 | end 25 | end 26 | 27 | def test_should_require_login_on_signup 28 | assert_no_difference 'User.count' do 29 | create_user(:login => nil) 30 | assert assigns(:user).errors.on(:login) 31 | assert_response :success 32 | end 33 | end 34 | 35 | def test_should_require_password_on_signup 36 | assert_no_difference 'User.count' do 37 | create_user(:password => nil) 38 | assert assigns(:user).errors.on(:password) 39 | assert_response :success 40 | end 41 | end 42 | 43 | def test_should_require_password_confirmation_on_signup 44 | assert_no_difference 'User.count' do 45 | create_user(:password_confirmation => nil) 46 | assert assigns(:user).errors.on(:password_confirmation) 47 | assert_response :success 48 | end 49 | end 50 | 51 | def test_should_require_email_on_signup 52 | assert_no_difference 'User.count' do 53 | create_user(:email => nil) 54 | assert assigns(:user).errors.on(:email) 55 | assert_response :success 56 | end 57 | end 58 | 59 | 60 | protected 61 | def create_user(options = {}) 62 | post :create, :captcha => 'test', :captcha_guide => 'a94a8f', :user => { :login => 'quire', :email => 'quire@example.com', 63 | :password => 'quire', :password_confirmation => 'quire' }.merge(options) 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /test/integration/stories_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class StoriesTest < ActionController::IntegrationTest 4 | fixtures :all 5 | 6 | def test_404 7 | get "/items/nosuchitem" 8 | assert_response :missing 9 | end 10 | 11 | def test_no_login_and_no_edit 12 | get "/items/MyString1" 13 | assert_response :success 14 | end 15 | 16 | def test_failed_edit_then_login_and_edit 17 | get "/items/edit/MyString1" 18 | assert_response :redirect 19 | post "/session", :login => 'quentin', :password => 'test' 20 | assert_response :redirect 21 | get "/items/edit/MyString1" 22 | assert_response :success 23 | end 24 | 25 | def test_non_admin_login_to_test_edit 26 | post "/session", :login => 'quentin', :password => 'test' 27 | assert_response :redirect 28 | get "/items/edit/MyString1" 29 | assert_response :success 30 | end 31 | end -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] = "test" 2 | require File.expand_path(File.dirname(__FILE__) + "/../config/environment") 3 | require 'test_help' 4 | 5 | require 'factory_girl' 6 | Dir[File.join(RAILS_ROOT, 'test', 'factories', '*')].each do |file| 7 | require file 8 | end 9 | 10 | class Test::Unit::TestCase 11 | # Transactional fixtures accelerate your tests by wrapping each test method 12 | # in a transaction that's rolled back on completion. This ensures that the 13 | # test database remains unchanged so your fixtures don't have to be reloaded 14 | # between every test method. Fewer database queries means faster tests. 15 | # 16 | # Read Mike Clark's excellent walkthrough at 17 | # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting 18 | # 19 | # Every Active Record database supports transactions except MyISAM tables 20 | # in MySQL. Turn off transactional fixtures in this case; however, if you 21 | # don't care one way or the other, switching from MyISAM to InnoDB tables 22 | # is recommended. 23 | # 24 | # The only drawback to using transactional fixtures is when you actually 25 | # need to test transactions. Since your test is bracketed by a transaction, 26 | # any transactions started in your code will be automatically rolled back. 27 | self.use_transactional_fixtures = true 28 | 29 | # Instantiated fixtures are slow, but give you @david where otherwise you 30 | # would need people(:david). If you don't want to migrate your existing 31 | # test cases which use the @david style and don't mind the speed hit (each 32 | # instantiated fixtures translates to a database query per test method), 33 | # then set this back to true. 34 | self.use_instantiated_fixtures = false 35 | 36 | # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. 37 | # 38 | # Note: You'll currently still have to declare fixtures explicitly in integration tests 39 | # -- they do not yet inherit this setting 40 | fixtures :all 41 | 42 | # Add more helper methods to be used by all tests here... 43 | include AuthenticatedTestHelper 44 | end 45 | -------------------------------------------------------------------------------- /test/unit/category_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class CategoryTest < ActiveSupport::TestCase 4 | 5 | should_require_attributes :title, :parent_id 6 | should_ensure_length_in_range :title, (4..255) 7 | should_require_unique_attributes :name 8 | should_ensure_length_in_range :name, (4..255) 9 | # TODO test validates_format_of values 10 | 11 | context 'Category with a short name' do 12 | setup do 13 | @category = Category.create(:name => 'yuk') 14 | end 15 | 16 | should 'use id for #to_param' do 17 | assert_equal @category.id, @category.to_param 18 | end 19 | end 20 | 21 | context 'Category with long name' do 22 | setup do 23 | @category = Category.create(:name => 'ever-so-slightly-longer') 24 | end 25 | 26 | should 'use name for #to_param' do 27 | assert_equal @category.name, @category.to_param 28 | end 29 | end 30 | 31 | # TODO contexts for Category with short/long title to test publicly_facing_name 32 | end 33 | -------------------------------------------------------------------------------- /test/unit/comment_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class CommentTest < ActiveSupport::TestCase 4 | should_belong_to :user 5 | should_belong_to :item 6 | 7 | should_ensure_length_in_range :content, (1..10000) 8 | end 9 | -------------------------------------------------------------------------------- /test/unit/item_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class ItemTest < ActiveSupport::TestCase 4 | should_belong_to :user 5 | should_have_many :comments 6 | should_have_many :stars 7 | 8 | should_ensure_length_in_range :title, (4..255) 9 | should_ensure_length_in_range :name, (4..255) 10 | should_ensure_length_in_range :content, (25..1200) 11 | 12 | # TODO test tagging stuff 13 | 14 | context 'An Item' do 15 | setup do 16 | @item = Factory(:item, :name => 'ihasname') 17 | end 18 | 19 | should_require_unique_attributes :name 20 | 21 | should_allow_values_for :name, 'name-1', 'name_1' 22 | should_not_allow_values_for :name, 'name 1' 23 | 24 | should_allow_values_for :tags, ':foo :bar' 25 | 26 | should 'use name for #to_param' do 27 | assert_equal @item.name, @item.to_param 28 | end 29 | 30 | context 'that has been starred by a user' do 31 | setup do 32 | @user = Factory(:user) 33 | @user.stars.create(:item => @item) 34 | end 35 | 36 | should 'be starred by user' do 37 | assert @item.is_starred_by_user(@user) 38 | end 39 | 40 | should 'generate starred css class' do 41 | assert_equal 'starred', @item.starred_class(@user) 42 | end 43 | end 44 | 45 | context 'that has not been starred by a user' do 46 | setup do 47 | @user = Factory(:user) 48 | end 49 | 50 | should 'be starred by user' do 51 | assert !@item.is_starred_by_user(@user) 52 | end 53 | 54 | should 'generate empty css class' do 55 | assert_equal '', @item.starred_class(@user) 56 | end 57 | end 58 | end 59 | 60 | context 'An Item without a name' do 61 | setup do 62 | @item = Factory(:item, :name => nil) 63 | end 64 | 65 | should 'use id for #to_param' do 66 | assert_equal @item.id, @item.to_param 67 | end 68 | end 69 | 70 | # context 71 | 72 | fixtures :users 73 | 74 | # FIXME fails to save 75 | # def test_can_add_item_with_no_name 76 | # item = Item.new(:title => "Title", :user => users(:quentin)) 77 | # assert item.save 78 | # end 79 | 80 | def test_cant_add_item_with_bad_name 81 | item = Item.new(:title => "Title", :name => "this is a test", :user => users(:quentin)) 82 | assert !item.save 83 | end 84 | 85 | end -------------------------------------------------------------------------------- /test/unit/star_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class StarTest < ActiveSupport::TestCase 4 | should_belong_to :user 5 | should_belong_to :item 6 | 7 | # TODO test uniqueness of user_id to item_id 8 | end 9 | -------------------------------------------------------------------------------- /tmp/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/tmp/.gitignore -------------------------------------------------------------------------------- /vendor/plugins/acts_as_state_machine/CHANGELOG: -------------------------------------------------------------------------------- 1 | * trunk * 2 | break with true value [Kaspar Schiess] 3 | 4 | * 2.1 * 5 | After actions [Saimon Moore] 6 | 7 | * 2.0 * (2006-01-20 15:26:28 -0500) 8 | Enter / Exit actions 9 | Transition guards 10 | Guards and actions can be a symbol pointing to a method or a Proc 11 | 12 | * 1.0 * (2006-01-15 12:16:55 -0500) 13 | Initial Release 14 | -------------------------------------------------------------------------------- /vendor/plugins/acts_as_state_machine/MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006 Scott Barron 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/plugins/acts_as_state_machine/README: -------------------------------------------------------------------------------- 1 | = Acts As State Machine 2 | 3 | This act gives an Active Record model the ability to act as a finite state 4 | machine (FSM). 5 | 6 | Acquire via subversion at: 7 | 8 | http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk 9 | 10 | If prompted, use the user/pass anonymous/anonymous. 11 | 12 | == Example 13 | 14 | class Order < ActiveRecord::Base 15 | acts_as_state_machine :initial => :opened 16 | 17 | state :opened 18 | state :closed, :enter => Proc.new {|o| Mailer.send_notice(o)} 19 | state :returned 20 | 21 | event :close do 22 | transitions :to => :closed, :from => :opened 23 | end 24 | 25 | event :return do 26 | transitions :to => :returned, :from => :closed 27 | end 28 | end 29 | 30 | o = Order.create 31 | o.close! # notice is sent by mailer 32 | o.return! 33 | 34 | -------------------------------------------------------------------------------- /vendor/plugins/acts_as_state_machine/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rake/testtask' 3 | require 'rake/rdoctask' 4 | 5 | desc 'Default: run unit tests.' 6 | task :default => [:clean_db, :test] 7 | 8 | desc 'Remove the stale db file' 9 | task :clean_db do 10 | `rm -f #{File.dirname(__FILE__)}/test/state_machine.sqlite.db` 11 | end 12 | 13 | desc 'Test the acts as state machine plugin.' 14 | Rake::TestTask.new(:test) do |t| 15 | t.libs << 'lib' 16 | t.pattern = 'test/**/*_test.rb' 17 | t.verbose = true 18 | end 19 | 20 | desc 'Generate documentation for the acts as state machine plugin.' 21 | Rake::RDocTask.new(:rdoc) do |rdoc| 22 | rdoc.rdoc_dir = 'rdoc' 23 | rdoc.title = 'Acts As State Machine' 24 | rdoc.options << '--line-numbers --inline-source' 25 | rdoc.rdoc_files.include('README') 26 | rdoc.rdoc_files.include('TODO') 27 | rdoc.rdoc_files.include('lib/**/*.rb') 28 | end 29 | -------------------------------------------------------------------------------- /vendor/plugins/acts_as_state_machine/TODO: -------------------------------------------------------------------------------- 1 | * Currently invalid events are ignored, create an option so that they can be 2 | ignored or raise an exception. 3 | 4 | * Query for a list of possible next states. 5 | 6 | * Make listing states optional since they can be inferred from the events. 7 | Only required to list a state if you want to define a transition block for it. 8 | 9 | * Real transition actions 10 | 11 | * Default states 12 | -------------------------------------------------------------------------------- /vendor/plugins/acts_as_state_machine/init.rb: -------------------------------------------------------------------------------- 1 | require 'acts_as_state_machine' 2 | 3 | ActiveRecord::Base.class_eval do 4 | include ScottBarron::Acts::StateMachine 5 | end 6 | -------------------------------------------------------------------------------- /vendor/plugins/acts_as_state_machine/test/database.yml: -------------------------------------------------------------------------------- 1 | sqlite: 2 | :adapter: sqlite 3 | :dbfile: state_machine.sqlite.db 4 | sqlite3: 5 | :adapter: sqlite3 6 | :dbfile: state_machine.sqlite3.db 7 | postgresql: 8 | :adapter: postgresql 9 | :username: postgres 10 | :password: postgres 11 | :database: state_machine_test 12 | :min_messages: ERROR 13 | mysql: 14 | :adapter: mysql 15 | :host: localhost 16 | :username: rails 17 | :password: 18 | :database: state_machine_test -------------------------------------------------------------------------------- /vendor/plugins/acts_as_state_machine/test/fixtures/conversation.rb: -------------------------------------------------------------------------------- 1 | class Conversation < ActiveRecord::Base 2 | attr_writer :can_close 3 | attr_accessor :read_enter, :read_exit, :read_after_first, :read_after_second, 4 | :closed_after, :needs_attention_enter, :needs_attention_after 5 | 6 | acts_as_state_machine :initial => :needs_attention, :column => 'state_machine' 7 | 8 | state :needs_attention, :enter => Proc.new { |o| o.needs_attention_enter = true }, 9 | :after => Proc.new { |o| o.needs_attention_after = true } 10 | 11 | state :read, :enter => :read_enter_action, 12 | :exit => Proc.new { |o| o.read_exit = true }, 13 | :after => [:read_after_first_action, :read_after_second_action] 14 | 15 | state :closed, :after => :closed_after_action 16 | state :awaiting_response 17 | state :junk 18 | 19 | event :new_message do 20 | transitions :to => :needs_attention, :from => [:read, :closed, :awaiting_response] 21 | end 22 | 23 | event :view do 24 | transitions :to => :read, :from => [:needs_attention, :read] 25 | end 26 | 27 | event :reply do 28 | transitions :to => :awaiting_response, :from => [:read, :closed] 29 | end 30 | 31 | event :close do 32 | transitions :to => :closed, :from => [:read, :awaiting_response], :guard => Proc.new {|o| o.can_close?} 33 | transitions :to => :read, :from => [:read, :awaiting_response], :guard => :always_true 34 | end 35 | 36 | event :junk, :note => "finished" do 37 | transitions :to => :junk, :from => [:read, :closed, :awaiting_response] 38 | end 39 | 40 | event :unjunk do 41 | transitions :to => :closed, :from => :junk 42 | end 43 | 44 | def can_close? 45 | @can_close 46 | end 47 | 48 | def read_enter_action 49 | self.read_enter = true 50 | end 51 | 52 | def always_true 53 | true 54 | end 55 | 56 | def read_after_first_action 57 | self.read_after_first = true 58 | end 59 | 60 | def read_after_second_action 61 | self.read_after_second = true 62 | end 63 | 64 | def closed_after_action 65 | self.closed_after = true 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /vendor/plugins/acts_as_state_machine/test/fixtures/conversations.yml: -------------------------------------------------------------------------------- 1 | first: 2 | id: 1 3 | state_machine: read 4 | subject: This is a test 5 | closed: false 6 | 7 | second: 8 | id: 2 9 | state_machine: read 10 | subject: Foo 11 | closed: false 12 | -------------------------------------------------------------------------------- /vendor/plugins/acts_as_state_machine/test/fixtures/person.rb: -------------------------------------------------------------------------------- 1 | class Person < ActiveRecord::Base 2 | end -------------------------------------------------------------------------------- /vendor/plugins/acts_as_state_machine/test/schema.rb: -------------------------------------------------------------------------------- 1 | ActiveRecord::Schema.define(:version => 1) do 2 | create_table :conversations, :force => true do |t| 3 | t.column :state_machine, :string 4 | t.column :subject, :string 5 | t.column :closed, :boolean 6 | end 7 | 8 | create_table :people, :force => true do |t| 9 | t.column :name, :string 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /vendor/plugins/acts_as_state_machine/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | $:.unshift(File.dirname(__FILE__) + '/../lib') 2 | RAILS_ROOT = File.dirname(__FILE__) 3 | 4 | require 'rubygems' 5 | require 'test/unit' 6 | require 'active_record' 7 | require 'active_record/fixtures' 8 | require 'active_support/binding_of_caller' 9 | require 'active_support/breakpoint' 10 | require "#{File.dirname(__FILE__)}/../init" 11 | 12 | 13 | config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')) 14 | ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log") 15 | ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite']) 16 | 17 | load(File.dirname(__FILE__) + "/schema.rb") if File.exist?(File.dirname(__FILE__) + "/schema.rb") 18 | 19 | Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/" 20 | $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path) 21 | 22 | class Test::Unit::TestCase #:nodoc: 23 | def create_fixtures(*table_names) 24 | if block_given? 25 | Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield } 26 | else 27 | Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) 28 | end 29 | end 30 | 31 | # Turn off transactional fixtures if you're working with MyISAM tables in MySQL 32 | self.use_transactional_fixtures = true 33 | 34 | # Instantiated fixtures are slow, but give you @david where you otherwise would need people(:david) 35 | self.use_instantiated_fixtures = false 36 | 37 | # Add more helper methods to be used by all tests here... 38 | end -------------------------------------------------------------------------------- /vendor/plugins/acts_as_tree/README: -------------------------------------------------------------------------------- 1 | acts_as_tree 2 | ============ 3 | 4 | Specify this +acts_as+ extension if you want to model a tree structure by providing a parent association and a children 5 | association. This requires that you have a foreign key column, which by default is called +parent_id+. 6 | 7 | class Category < ActiveRecord::Base 8 | acts_as_tree :order => "name" 9 | end 10 | 11 | Example: 12 | root 13 | \_ child1 14 | \_ subchild1 15 | \_ subchild2 16 | 17 | root = Category.create("name" => "root") 18 | child1 = root.children.create("name" => "child1") 19 | subchild1 = child1.children.create("name" => "subchild1") 20 | 21 | root.parent # => nil 22 | child1.parent # => root 23 | root.children # => [child1] 24 | root.children.first.children.first # => subchild1 25 | 26 | Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license -------------------------------------------------------------------------------- /vendor/plugins/acts_as_tree/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rake/testtask' 3 | require 'rake/rdoctask' 4 | 5 | desc 'Default: run unit tests.' 6 | task :default => :test 7 | 8 | desc 'Test acts_as_tree plugin.' 9 | Rake::TestTask.new(:test) do |t| 10 | t.libs << 'lib' 11 | t.pattern = 'test/**/*_test.rb' 12 | t.verbose = true 13 | end 14 | 15 | desc 'Generate documentation for acts_as_tree plugin.' 16 | Rake::RDocTask.new(:rdoc) do |rdoc| 17 | rdoc.rdoc_dir = 'rdoc' 18 | rdoc.title = 'acts_as_tree' 19 | rdoc.options << '--line-numbers' << '--inline-source' 20 | rdoc.rdoc_files.include('README') 21 | rdoc.rdoc_files.include('lib/**/*.rb') 22 | end 23 | -------------------------------------------------------------------------------- /vendor/plugins/acts_as_tree/init.rb: -------------------------------------------------------------------------------- 1 | ActiveRecord::Base.send :include, ActiveRecord::Acts::Tree 2 | -------------------------------------------------------------------------------- /vendor/plugins/acts_as_tree/test/abstract_unit.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/acts_as_tree/test/abstract_unit.rb -------------------------------------------------------------------------------- /vendor/plugins/acts_as_tree/test/database.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/acts_as_tree/test/database.yml -------------------------------------------------------------------------------- /vendor/plugins/acts_as_tree/test/fixtures/mixin.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb -------------------------------------------------------------------------------- /vendor/plugins/acts_as_tree/test/fixtures/mixins.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml -------------------------------------------------------------------------------- /vendor/plugins/acts_as_tree/test/schema.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/acts_as_tree/test/schema.rb -------------------------------------------------------------------------------- /vendor/plugins/jrails/CHANGELOG: -------------------------------------------------------------------------------- 1 | SVN 2 | * can now use jquery selectors in all functions 3 | * added javascript_function helper to render inline rjs helpers 4 | * better support for sortable_element 5 | * updated to jquery-ui 1.5.1 6 | 7 | 0.4.0 (16 June 2008) 8 | * updated to jquery-ui 1.5 & merged js into single file 9 | * Added jQuery.noConflict support 10 | * support for value/val 11 | * additional support for update/delete methods 12 | * support for success/failure hash 13 | * setRequestHeader now gets called globally 14 | * Better support for droppables, sortables 15 | * Add support for prototype AJAX callbacks 16 | * better support for AJAX form calls 17 | 18 | 0.3.0 (22 Feb 2008) 19 | * updated to jquery-fx 1.0b and jquery-ui 1.5b 20 | * Add text/javascript request header to fix format.js 21 | * Added Tasks (thanks ggarside) 22 | * Improve visual_effects methods 23 | * Fixed some RJS calls 24 | * Fixed observer code for ie 25 | 26 | 0.2.0 (26 Nov 2007) 27 | * Vastly Improved FX 28 | * Improved Form Observers 29 | * Fixed Rails <= 1.2.6 Compatibility 30 | 31 | 0.1.0 (15 Nov 2007) 32 | * Initial release 33 | -------------------------------------------------------------------------------- /vendor/plugins/jrails/README: -------------------------------------------------------------------------------- 1 | = jRails 2 | 3 | jRails is a drop-in jQuery replacement for the Rails Prototype/script.aculo.us helpers. 4 | 5 | == Resources 6 | 7 | Install 8 | 9 | * .script/plugin install http://ennerchi.googlecode.com/svn/trunk/plugins/jrails 10 | 11 | Project Site 12 | 13 | * http://code.google.com/p/ennerchi/ 14 | 15 | Web Site 16 | 17 | * http://www.ennerchi.com/projects/jrails 18 | 19 | Group Site 20 | 21 | * http://groups.google.com/group/jrails -------------------------------------------------------------------------------- /vendor/plugins/jrails/init.rb: -------------------------------------------------------------------------------- 1 | # uncomment to use jQuery.noConflict() 2 | #ActionView::Helpers::PrototypeHelper::JQUERY_VAR = 'jQuery' 3 | 4 | ActionView::Helpers::AssetTagHelper::JAVASCRIPT_DEFAULT_SOURCES = ['jquery','jquery-ui','jrails'] 5 | ActionView::Helpers::AssetTagHelper::reset_javascript_include_default 6 | require 'jrails' -------------------------------------------------------------------------------- /vendor/plugins/jrails/install.rb: -------------------------------------------------------------------------------- 1 | # Install hook code here 2 | puts "Copying files..." 3 | dir = "javascripts" 4 | ["jquery-ui.js", "jquery.js", "jrails.js"].each do |js_file| 5 | dest_file = File.join(RAILS_ROOT, "public", dir, js_file) 6 | src_file = File.join(File.dirname(__FILE__) , dir, js_file) 7 | FileUtils.cp_r(src_file, dest_file) 8 | end 9 | puts "Files copied - Installation complete!" 10 | -------------------------------------------------------------------------------- /vendor/plugins/jrails/tasks/jrails.rake: -------------------------------------------------------------------------------- 1 | namespace :jrails do 2 | namespace :update do 3 | desc "Copies the jQuery and jRails javascripts to public/javascripts" 4 | task :javascripts do 5 | puts "Copying files..." 6 | project_dir = RAILS_ROOT + '/public/javascripts/' 7 | scripts = Dir[File.join(File.dirname(__FILE__), '..') + '/javascripts/*.js'] 8 | FileUtils.cp(scripts, project_dir) 9 | puts "files copied successfully." 10 | end 11 | end 12 | 13 | namespace :install do 14 | desc "Installs the jQuery and jRails javascripts to public/javascripts" 15 | task :javascripts do 16 | Rake::Task['jrails:update:javascripts'].invoke 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/README: -------------------------------------------------------------------------------- 1 | Restful Authentication Generator 2 | ==== 3 | 4 | This is a basic restful authentication generator for rails, taken 5 | from acts as authenticated. Currently it requires Rails 1.2.6 or above. 6 | 7 | To use: 8 | 9 | ./script/generate authenticated user sessions \ 10 | --include-activation \ 11 | --stateful 12 | 13 | The first parameter specifies the model that gets created in signup 14 | (typically a user or account model). A model with migration is 15 | created, as well as a basic controller with the create method. 16 | 17 | The second parameter specifies the sessions controller name. This is 18 | the controller that handles the actual login/logout function on the 19 | site. 20 | 21 | The third parameter (--include-activation) generates the code for a 22 | ActionMailer and its respective Activation Code through email. 23 | 24 | The fourth (--stateful) builds in support for acts_as_state_machine 25 | and generates activation code. This was taken from: 26 | 27 | http://www.vaporbase.com/postings/stateful_authentication 28 | 29 | You can pass --skip-migration to skip the user migration. 30 | 31 | If you're using acts_as_state_machine, define your users resource like this: 32 | 33 | map.resources :users, :member => { :suspend => :put, 34 | :unsuspend => :put, 35 | :purge => :delete } 36 | 37 | Also, add an observer to config/environment.rb if you chose the 38 | --include-activation option 39 | 40 | config.active_record.observers = :user_observer # or whatever you 41 | # named your model 42 | 43 | Security Alert 44 | ==== 45 | 46 | I introduced a change to the model controller that's been tripping 47 | folks up on Rails 2.0. The change was added as a suggestion to help 48 | combat session fixation attacks. However, this resets the Form 49 | Authentication token used by Request Forgery Protection. I've left 50 | it out now, since Rails 1.2.6 and Rails 2.0 will both stop session 51 | fixation attacks anyway. -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rake/testtask' 3 | require 'rake/rdoctask' 4 | 5 | desc 'Default: run unit tests.' 6 | task :default => :test 7 | 8 | desc 'Test the restful_authentication plugin.' 9 | Rake::TestTask.new(:test) do |t| 10 | t.libs << 'lib' 11 | t.pattern = 'test/**/*_test.rb' 12 | t.verbose = true 13 | end 14 | 15 | desc 'Generate documentation for the restful_authentication plugin.' 16 | Rake::RDocTask.new(:rdoc) do |rdoc| 17 | rdoc.rdoc_dir = 'rdoc' 18 | rdoc.title = 'RestfulAuthentication' 19 | rdoc.options << '--line-numbers' << '--inline-source' 20 | rdoc.rdoc_files.include('README') 21 | rdoc.rdoc_files.include('lib/**/*.rb') 22 | end 23 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/USAGE: -------------------------------------------------------------------------------- 1 | ./script/generate authenticated USERMODEL CONTROLLERNAME -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/activation.html.erb: -------------------------------------------------------------------------------- 1 | <%%= @<%= file_name %>.login %>, your account has been activated. You may now start adding your plugins: 2 | 3 | <%%= @url %> -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb: -------------------------------------------------------------------------------- 1 | module AuthenticatedTestHelper 2 | # Sets the current <%= file_name %> in the session from the <%= file_name %> fixtures. 3 | def login_as(<%= file_name %>) 4 | @request.session[:<%= file_name %>_id] = <%= file_name %> ? <%= table_name %>(<%= file_name %>).id : nil 5 | end 6 | 7 | def authorize_as(user) 8 | @request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentication::Basic.encode_credentials(users(user).login, 'test') : nil 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb: -------------------------------------------------------------------------------- 1 | # This controller handles the login/logout function of the site. 2 | class <%= controller_class_name %>Controller < ApplicationController 3 | # Be sure to include AuthenticationSystem in Application Controller instead 4 | include AuthenticatedSystem 5 | 6 | # render new.rhtml 7 | def new 8 | end 9 | 10 | def create 11 | self.current_<%= file_name %> = <%= class_name %>.authenticate(params[:login], params[:password]) 12 | if logged_in? 13 | if params[:remember_me] == "1" 14 | self.current_<%= file_name %>.remember_me 15 | cookies[:auth_token] = { :value => self.current_<%= file_name %>.remember_token , :expires => self.current_<%= file_name %>.remember_token_expires_at } 16 | end 17 | redirect_back_or_default('/') 18 | flash[:notice] = "Logged in successfully" 19 | else 20 | render :action => 'new' 21 | end 22 | end 23 | 24 | def destroy 25 | self.current_<%= file_name %>.forget_me if logged_in? 26 | cookies.delete :auth_token 27 | reset_session 28 | flash[:notice] = "You have been logged out." 29 | redirect_back_or_default('/') 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/fixtures.yml: -------------------------------------------------------------------------------- 1 | quentin: 2 | id: 1 3 | login: quentin 4 | email: quentin@example.com 5 | salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd 6 | crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test 7 | created_at: <%%= 5.days.ago.to_s :db %> 8 | <% if options[:include_activation] %> activation_code: 8f24789ae988411ccf33ab0c30fe9106fab32e9b <% end %> 9 | <% if options[:include_activation] %> activated_at: <%%= 5.days.ago.to_s :db %> <% end %> 10 | <% if options[:stateful] %> state: active<% end %> 11 | aaron: 12 | id: 2 13 | login: aaron 14 | email: aaron@example.com 15 | salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd 16 | crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test 17 | created_at: <%%= 1.days.ago.to_s :db %> 18 | <% if options[:include_activation] %> activation_code: 8f24789ae988411ccf33ab0c30fe9106fab32e9a <% end %> 19 | <% if options[:stateful] %> state: pending<% end %> 20 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/functional_spec.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../spec_helper' 2 | 3 | # Be sure to include AuthenticatedTestHelper in spec/spec_helper.rb instead 4 | # Then, you can remove it from this and the units test. 5 | include AuthenticatedTestHelper 6 | 7 | describe <%= controller_class_name %>Controller do 8 | fixtures :<%= table_name %> 9 | 10 | it 'logins and redirects' do 11 | post :create, :login => 'quentin', :password => 'test' 12 | session[:<%= file_name %>_id].should_not be_nil 13 | response.should be_redirect 14 | end 15 | 16 | it 'fails login and does not redirect' do 17 | post :create, :login => 'quentin', :password => 'bad password' 18 | session[:<%= file_name %>_id].should be_nil 19 | response.should be_success 20 | end 21 | 22 | it 'logs out' do 23 | login_as :quentin 24 | get :destroy 25 | session[:<%= file_name %>_id].should be_nil 26 | response.should be_redirect 27 | end 28 | 29 | it 'remembers me' do 30 | post :create, :login => 'quentin', :password => 'test', :remember_me => "1" 31 | response.cookies["auth_token"].should_not be_nil 32 | end 33 | 34 | it 'does not remember me' do 35 | post :create, :login => 'quentin', :password => 'test', :remember_me => "0" 36 | response.cookies["auth_token"].should be_nil 37 | end 38 | 39 | it 'deletes token on logout' do 40 | login_as :quentin 41 | get :destroy 42 | response.cookies["auth_token"].should == [] 43 | end 44 | 45 | it 'logs in with cookie' do 46 | <%= table_name %>(:quentin).remember_me 47 | request.cookies["auth_token"] = cookie_for(:quentin) 48 | get :new 49 | controller.send(:logged_in?).should be_true 50 | end 51 | 52 | it 'fails expired cookie login' do 53 | <%= table_name %>(:quentin).remember_me 54 | <%= table_name %>(:quentin).update_attribute :remember_token_expires_at, 5.minutes.ago 55 | request.cookies["auth_token"] = cookie_for(:quentin) 56 | get :new 57 | controller.send(:logged_in?).should_not be_true 58 | end 59 | 60 | it 'fails cookie login' do 61 | <%= table_name %>(:quentin).remember_me 62 | request.cookies["auth_token"] = auth_token('invalid_auth_token') 63 | get :new 64 | controller.send(:logged_in?).should_not be_true 65 | end 66 | 67 | def auth_token(token) 68 | CGI::Cookie.new('name' => 'auth_token', 'value' => token) 69 | end 70 | 71 | def cookie_for(<%= file_name %>) 72 | auth_token <%= table_name %>(<%= file_name %>).remember_token 73 | end 74 | end 75 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/functional_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | require '<%= controller_file_name %>_controller' 3 | 4 | # Re-raise errors caught by the controller. 5 | class <%= controller_class_name %>Controller; def rescue_action(e) raise e end; end 6 | 7 | class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase 8 | # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead 9 | # Then, you can remove it from this and the units test. 10 | include AuthenticatedTestHelper 11 | 12 | fixtures :<%= table_name %> 13 | 14 | def setup 15 | @controller = <%= controller_class_name %>Controller.new 16 | @request = ActionController::TestRequest.new 17 | @response = ActionController::TestResponse.new 18 | end 19 | 20 | def test_should_login_and_redirect 21 | post :create, :login => 'quentin', :password => 'test' 22 | assert session[:<%= file_name %>_id] 23 | assert_response :redirect 24 | end 25 | 26 | def test_should_fail_login_and_not_redirect 27 | post :create, :login => 'quentin', :password => 'bad password' 28 | assert_nil session[:<%= file_name %>_id] 29 | assert_response :success 30 | end 31 | 32 | def test_should_logout 33 | login_as :quentin 34 | get :destroy 35 | assert_nil session[:<%= file_name %>_id] 36 | assert_response :redirect 37 | end 38 | 39 | def test_should_remember_me 40 | post :create, :login => 'quentin', :password => 'test', :remember_me => "1" 41 | assert_not_nil @response.cookies["auth_token"] 42 | end 43 | 44 | def test_should_not_remember_me 45 | post :create, :login => 'quentin', :password => 'test', :remember_me => "0" 46 | assert_nil @response.cookies["auth_token"] 47 | end 48 | 49 | def test_should_delete_token_on_logout 50 | login_as :quentin 51 | get :destroy 52 | assert_equal @response.cookies["auth_token"], [] 53 | end 54 | 55 | def test_should_login_with_cookie 56 | <%= table_name %>(:quentin).remember_me 57 | @request.cookies["auth_token"] = cookie_for(:quentin) 58 | get :new 59 | assert @controller.send(:logged_in?) 60 | end 61 | 62 | def test_should_fail_expired_cookie_login 63 | <%= table_name %>(:quentin).remember_me 64 | <%= table_name %>(:quentin).update_attribute :remember_token_expires_at, 5.minutes.ago 65 | @request.cookies["auth_token"] = cookie_for(:quentin) 66 | get :new 67 | assert !@controller.send(:logged_in?) 68 | end 69 | 70 | def test_should_fail_cookie_login 71 | <%= table_name %>(:quentin).remember_me 72 | @request.cookies["auth_token"] = auth_token('invalid_auth_token') 73 | get :new 74 | assert !@controller.send(:logged_in?) 75 | end 76 | 77 | protected 78 | def auth_token(token) 79 | CGI::Cookie.new('name' => 'auth_token', 'value' => token) 80 | end 81 | 82 | def cookie_for(<%= file_name %>) 83 | auth_token <%= table_name %>(<%= file_name %>).remember_token 84 | end 85 | end 86 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/helper.rb: -------------------------------------------------------------------------------- 1 | module <%= controller_class_name %>Helper 2 | end -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/login.html.erb: -------------------------------------------------------------------------------- 1 | <%% form_tag <%= controller_singular_name %>_path do -%> 2 |


3 | <%%= text_field_tag 'login' %>

4 | 5 |


6 | <%%= password_field_tag 'password' %>

7 | 8 | 12 | 13 |

<%%= submit_tag 'Log in' %>

14 | <%% end -%> 15 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/mailer.rb: -------------------------------------------------------------------------------- 1 | class <%= class_name %>Mailer < ActionMailer::Base 2 | def signup_notification(<%= file_name %>) 3 | setup_email(<%= file_name %>) 4 | @subject += 'Please activate your new account' 5 | <% if options[:include_activation] %> 6 | @body[:url] = "http://YOURSITE/activate/#{<%= file_name %>.activation_code}" 7 | <% else %> 8 | @body[:url] = "http://YOURSITE/login/" <% end %> 9 | end 10 | 11 | def activation(<%= file_name %>) 12 | setup_email(<%= file_name %>) 13 | @subject += 'Your account has been activated!' 14 | @body[:url] = "http://YOURSITE/" 15 | end 16 | 17 | protected 18 | def setup_email(<%= file_name %>) 19 | @recipients = "#{<%= file_name %>.email}" 20 | @from = "ADMINEMAIL" 21 | @subject = "[YOURSITE] " 22 | @sent_on = Time.now 23 | @body[:<%= file_name %>] = <%= file_name %> 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/mailer_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | require '<%= file_name %>_mailer' 3 | 4 | class <%= class_name %>MailerTest < Test::Unit::TestCase 5 | FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures' 6 | CHARSET = "utf-8" 7 | 8 | include ActionMailer::Quoting 9 | 10 | def setup 11 | ActionMailer::Base.delivery_method = :test 12 | ActionMailer::Base.perform_deliveries = true 13 | ActionMailer::Base.deliveries = [] 14 | 15 | @expected = TMail::Mail.new 16 | @expected.set_content_type "text", "plain", { "charset" => CHARSET } 17 | end 18 | 19 | def test_dummy_test 20 | #do nothing 21 | end 22 | 23 | private 24 | def read_fixture(action) 25 | IO.readlines("#{FIXTURES_PATH}/<%= file_name %>_mailer/#{action}") 26 | end 27 | 28 | def encode(subject) 29 | quoted_printable(subject, CHARSET) 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/migration.rb: -------------------------------------------------------------------------------- 1 | class <%= migration_name %> < ActiveRecord::Migration 2 | def self.up 3 | create_table "<%= table_name %>", :force => true do |t| 4 | t.column :login, :string 5 | t.column :email, :string 6 | t.column :crypted_password, :string, :limit => 40 7 | t.column :salt, :string, :limit => 40 8 | t.column :created_at, :datetime 9 | t.column :updated_at, :datetime 10 | t.column :remember_token, :string 11 | t.column :remember_token_expires_at, :datetime 12 | <% if options[:include_activation] %>t.column :activation_code, :string, :limit => 40 13 | t.column :activated_at, :datetime<% end %> 14 | <% if options[:stateful] %>t.column :state, :string, :null => :no, :default => 'passive' 15 | t.column :deleted_at, :datetime<% end %> 16 | end 17 | end 18 | 19 | def self.down 20 | drop_table "<%= table_name %>" 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/model_controller.rb: -------------------------------------------------------------------------------- 1 | class <%= model_controller_class_name %>Controller < ApplicationController 2 | # Be sure to include AuthenticationSystem in Application Controller instead 3 | include AuthenticatedSystem 4 | <% if options[:stateful] %> 5 | # Protect these actions behind an admin login 6 | # before_filter :admin_required, :only => [:suspend, :unsuspend, :destroy, :purge] 7 | before_filter :find_<%= file_name %>, :only => [:suspend, :unsuspend, :destroy, :purge] 8 | <% end %> 9 | 10 | # render new.rhtml 11 | def new 12 | end 13 | 14 | def create 15 | cookies.delete :auth_token 16 | # protects against session fixation attacks, wreaks havoc with 17 | # request forgery protection. 18 | # uncomment at your own risk 19 | # reset_session 20 | @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>]) 21 | @<%= file_name %>.<% if options[:stateful] %>register! if @<%= file_name %>.valid?<% else %>save<% end %> 22 | if @<%= file_name %>.errors.empty? 23 | self.current_<%= file_name %> = @<%= file_name %> 24 | redirect_back_or_default('/') 25 | flash[:notice] = "Thanks for signing up!" 26 | else 27 | render :action => 'new' 28 | end 29 | end 30 | <% if options[:include_activation] %> 31 | def activate 32 | self.current_<%= file_name %> = params[:activation_code].blank? ? :false : <%= class_name %>.find_by_activation_code(params[:activation_code]) 33 | if logged_in? && !current_<%= file_name %>.active? 34 | current_<%= file_name %>.activate<% if options[:stateful] %>!<% end %> 35 | flash[:notice] = "Signup complete!" 36 | end 37 | redirect_back_or_default('/') 38 | end 39 | <% end %><% if options[:stateful] %> 40 | def suspend 41 | @<%= file_name %>.suspend! 42 | redirect_to <%= table_name %>_path 43 | end 44 | 45 | def unsuspend 46 | @<%= file_name %>.unsuspend! 47 | redirect_to <%= table_name %>_path 48 | end 49 | 50 | def destroy 51 | @<%= file_name %>.delete! 52 | redirect_to <%= table_name %>_path 53 | end 54 | 55 | def purge 56 | @<%= file_name %>.destroy 57 | redirect_to <%= table_name %>_path 58 | end 59 | 60 | protected 61 | def find_<%= file_name %> 62 | @<%= file_name %> = <%= class_name %>.find(params[:id]) 63 | end 64 | <% end %> 65 | end 66 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/model_functional_spec.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../spec_helper' 2 | 3 | # Be sure to include AuthenticatedTestHelper in spec/spec_helper.rb instead 4 | # Then, you can remove it from this and the units test. 5 | include AuthenticatedTestHelper 6 | 7 | describe <%= model_controller_class_name %>Controller do 8 | fixtures :<%= table_name %> 9 | 10 | it 'allows signup' do 11 | lambda do 12 | create_<%= file_name %> 13 | response.should be_redirect 14 | end.should change(<%= class_name %>, :count).by(1) 15 | end 16 | 17 | <% if options[:stateful] %> 18 | it 'signs up user in pending state' do 19 | create_user 20 | assigns(:user).should be_pending 21 | end<% end %> 22 | 23 | <% if options[:include_activation] %> 24 | it 'signs up user with activation code' do 25 | create_user 26 | assigns(:user).activation_code.should_not be_nil 27 | end<% end %> 28 | 29 | it 'requires login on signup' do 30 | lambda do 31 | create_<%= file_name %>(:login => nil) 32 | assigns[:<%= file_name %>].errors.on(:login).should_not be_nil 33 | response.should be_success 34 | end.should_not change(<%= class_name %>, :count) 35 | end 36 | 37 | it 'requires password on signup' do 38 | lambda do 39 | create_<%= file_name %>(:password => nil) 40 | assigns[:<%= file_name %>].errors.on(:password).should_not be_nil 41 | response.should be_success 42 | end.should_not change(<%= class_name %>, :count) 43 | end 44 | 45 | it 'requires password confirmation on signup' do 46 | lambda do 47 | create_<%= file_name %>(:password_confirmation => nil) 48 | assigns[:<%= file_name %>].errors.on(:password_confirmation).should_not be_nil 49 | response.should be_success 50 | end.should_not change(<%= class_name %>, :count) 51 | end 52 | 53 | it 'requires email on signup' do 54 | lambda do 55 | create_<%= file_name %>(:email => nil) 56 | assigns[:<%= file_name %>].errors.on(:email).should_not be_nil 57 | response.should be_success 58 | end.should_not change(<%= class_name %>, :count) 59 | end 60 | 61 | <% if options[:include_activation] %> 62 | it 'activates user' do 63 | <%= class_name %>.authenticate('aaron', 'test').should be_nil 64 | get :activate, :activation_code => <%= table_name %>(:aaron).activation_code 65 | response.should redirect_to('/') 66 | flash[:notice].should_not be_nil 67 | <%= class_name %>.authenticate('aaron', 'test').should == <%= table_name %>(:aaron) 68 | end 69 | 70 | it 'does not activate user without key' do 71 | get :activate 72 | flash[:notice].should be_nil 73 | end 74 | 75 | it 'does not activate user with blank key' do 76 | get :activate, :activation_code => '' 77 | flash[:notice].should be_nil 78 | end<% end %> 79 | 80 | def create_<%= file_name %>(options = {}) 81 | post :create, :<%= file_name %> => { :login => 'quire', :email => 'quire@example.com', 82 | :password => 'quire', :password_confirmation => 'quire' }.merge(options) 83 | end 84 | end -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/model_functional_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | require '<%= model_controller_file_name %>_controller' 3 | 4 | # Re-raise errors caught by the controller. 5 | class <%= model_controller_class_name %>Controller; def rescue_action(e) raise e end; end 6 | 7 | class <%= model_controller_class_name %>ControllerTest < Test::Unit::TestCase 8 | # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead 9 | # Then, you can remove it from this and the units test. 10 | include AuthenticatedTestHelper 11 | 12 | fixtures :<%= table_name %> 13 | 14 | def setup 15 | @controller = <%= model_controller_class_name %>Controller.new 16 | @request = ActionController::TestRequest.new 17 | @response = ActionController::TestResponse.new 18 | end 19 | 20 | def test_should_allow_signup 21 | assert_difference '<%= class_name %>.count' do 22 | create_<%= file_name %> 23 | assert_response :redirect 24 | end 25 | end 26 | 27 | def test_should_require_login_on_signup 28 | assert_no_difference '<%= class_name %>.count' do 29 | create_<%= file_name %>(:login => nil) 30 | assert assigns(:<%= file_name %>).errors.on(:login) 31 | assert_response :success 32 | end 33 | end 34 | 35 | def test_should_require_password_on_signup 36 | assert_no_difference '<%= class_name %>.count' do 37 | create_<%= file_name %>(:password => nil) 38 | assert assigns(:<%= file_name %>).errors.on(:password) 39 | assert_response :success 40 | end 41 | end 42 | 43 | def test_should_require_password_confirmation_on_signup 44 | assert_no_difference '<%= class_name %>.count' do 45 | create_<%= file_name %>(:password_confirmation => nil) 46 | assert assigns(:<%= file_name %>).errors.on(:password_confirmation) 47 | assert_response :success 48 | end 49 | end 50 | 51 | def test_should_require_email_on_signup 52 | assert_no_difference '<%= class_name %>.count' do 53 | create_<%= file_name %>(:email => nil) 54 | assert assigns(:<%= file_name %>).errors.on(:email) 55 | assert_response :success 56 | end 57 | end 58 | <% if options[:include_activation] %> 59 | def test_should_activate_user 60 | assert_nil <%= class_name %>.authenticate('aaron', 'test') 61 | get :activate, :activation_code => <%= table_name %>(:aaron).activation_code 62 | assert_redirected_to '/' 63 | assert_not_nil flash[:notice] 64 | assert_equal <%= table_name %>(:aaron), <%= class_name %>.authenticate('aaron', 'test') 65 | end 66 | 67 | def test_should_not_activate_user_without_key 68 | get :activate 69 | assert_nil flash[:notice] 70 | rescue ActionController::RoutingError 71 | # in the event your routes deny this, we'll just bow out gracefully. 72 | end 73 | 74 | def test_should_not_activate_user_with_blank_key 75 | get :activate, :activation_code => '' 76 | assert_nil flash[:notice] 77 | rescue ActionController::RoutingError 78 | # well played, sir 79 | end<% end %> 80 | 81 | protected 82 | def create_<%= file_name %>(options = {}) 83 | post :create, :<%= file_name %> => { :login => 'quire', :email => 'quire@example.com', 84 | :password => 'quire', :password_confirmation => 'quire' }.merge(options) 85 | end 86 | end 87 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/model_helper.rb: -------------------------------------------------------------------------------- 1 | module <%= model_controller_class_name %>Helper 2 | end -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/observer.rb: -------------------------------------------------------------------------------- 1 | class <%= class_name %>Observer < ActiveRecord::Observer 2 | def after_create(<%= file_name %>) 3 | <%= class_name %>Mailer.deliver_signup_notification(<%= file_name %>) 4 | end 5 | 6 | def after_save(<%= file_name %>) 7 | <% if options[:include_activation] %> 8 | <%= class_name %>Mailer.deliver_activation(<%= file_name %>) if <%= file_name %>.pending? 9 | <% end %> 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/signup.html.erb: -------------------------------------------------------------------------------- 1 | <%%= error_messages_for :<%= file_name %> %> 2 | <%% form_for :<%= file_name %>, :url => <%= table_name %>_path do |f| -%> 3 |


4 | <%%= f.text_field :login %>

5 | 6 |


7 | <%%= f.text_field :email %>

8 | 9 |


10 | <%%= f.password_field :password %>

11 | 12 |


13 | <%%= f.password_field :password_confirmation %>

14 | 15 |

<%%= submit_tag 'Sign up' %>

16 | <%% end -%> 17 | -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/generators/authenticated/templates/signup_notification.html.erb: -------------------------------------------------------------------------------- 1 | Your account has been created. 2 | 3 | Username: <%%= @<%= file_name %>.login %> 4 | Password: <%%= @<%= file_name %>.password %> 5 | 6 | Visit this url to activate your account: 7 | 8 | <%%= @url %> -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/install.rb: -------------------------------------------------------------------------------- 1 | puts IO.read(File.join(File.dirname(__FILE__), 'README')) -------------------------------------------------------------------------------- /vendor/plugins/restful_authentication/lib/restful_authentication/rails_commands.rb: -------------------------------------------------------------------------------- 1 | Rails::Generator::Commands::Create.class_eval do 2 | def route_resource(*resources) 3 | resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') 4 | sentinel = 'ActionController::Routing::Routes.draw do |map|' 5 | 6 | logger.route "map.resource #{resource_list}" 7 | unless options[:pretend] 8 | gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match| 9 | "#{match}\n map.resource #{resource_list}\n" 10 | end 11 | end 12 | end 13 | end 14 | 15 | Rails::Generator::Commands::Destroy.class_eval do 16 | def route_resource(*resources) 17 | resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') 18 | look_for = "\n map.resource #{resource_list}\n" 19 | logger.route "map.resource #{resource_list}" 20 | gsub_file 'config/routes.rb', /(#{look_for})/mi, '' 21 | end 22 | end 23 | 24 | Rails::Generator::Commands::List.class_eval do 25 | def route_resource(*resources) 26 | resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') 27 | logger.route "map.resource #{resource_list}" 28 | end 29 | end -------------------------------------------------------------------------------- /vendor/plugins/shoulda/.autotest: -------------------------------------------------------------------------------- 1 | Autotest.add_hook :initialize do |at| 2 | at.add_mapping(%r{^lib/\w.*\.rb}) do 3 | at.files_matching(%r{^test/*/\w.*_test\.rb}) 4 | end 5 | 6 | at.add_mapping(%r{^test/rails_root/\w.*}) do 7 | at.files_matching(%r{^test/*/\w.*_test\.rb}) 8 | end 9 | 10 | at.add_exception(%r{.svn}) 11 | at.add_exception(%r{.log$}) 12 | at.add_exception(%r{^.autotest$}) 13 | end 14 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/.gitignore: -------------------------------------------------------------------------------- 1 | test/rails_root/log/*.log 2 | doc 3 | coverage 4 | .svn/ 5 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/CONTRIBUTION_GUIDELINES.rdoc: -------------------------------------------------------------------------------- 1 | We're using GitHub[http://github.com/thoughtbot/shoulda/tree/master] and Lighthouse[http://thoughtbot.lighthouseapp.com/projects/5807], and we've been getting any combination of github pull requests, Lighthouse tickets, patches, emails, etc. We need to normalize this workflow to make sure we don't miss any fixes. 2 | 3 | * Make sure you're accessing the source from the {official repository}[http://github.com/thoughtbot/shoulda/tree/master]. 4 | * We prefer git branches over patches, but we can take either. 5 | * If you're using git, please make a branch for each separate contribution. We can cherry pick your commits, but pulling from a branch is easier. 6 | * If you're submitting patches, please cut each fix or feature into a separate patch. 7 | * There should be a Lighthouse[http://thoughtbot.lighthouseapp.com/projects/5807] ticket for any submission. If you've found a bug and want to fix it, open a new ticket at the same time. 8 | * We've got github/lighthouse integration going, so you can update tickets when you commit. {This blog post}[http://hoth.entp.com/2008/4/11/github-and-lighthouse-sitting-in-a-tree] explains the commit options pretty well. 9 | * Please don't send pull requests Just update the lighthouse ticket with the url for your fix (or attach the patch) when it's ready. The github pull requests pretty much get dropped on the floor until someone with commit rights notices them in the mailbox. 10 | * Contributions without tests won't be accepted. The file /test/README explains the testing system pretty thoroughly. 11 | 12 | 13 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007, Tammer Saleh, Thoughtbot, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rake/testtask' 3 | require 'rake/rdoctask' 4 | 5 | # Test::Unit::UI::VERBOSE 6 | test_files_pattern = 'test/{unit,functional,other}/**/*_test.rb' 7 | Rake::TestTask.new do |t| 8 | t.libs << 'lib' 9 | t.pattern = test_files_pattern 10 | t.verbose = false 11 | end 12 | 13 | Rake::RDocTask.new { |rdoc| 14 | rdoc.rdoc_dir = 'doc' 15 | rdoc.title = "Shoulda -- Making tests easy on the fingers and eyes" 16 | rdoc.options << '--line-numbers' << '--inline-source' 17 | rdoc.template = "#{ENV['template']}.rb" if ENV['template'] 18 | rdoc.rdoc_files.include('README.rdoc', 'CONTRIBUTION_GUIDELINES.rdoc', 'lib/**/*.rb') 19 | } 20 | 21 | desc "Run code-coverage analysis using rcov" 22 | task :coverage do 23 | rm_rf "coverage" 24 | files = Dir[test_files_pattern] 25 | system "rcov --rails --sort coverage -Ilib #{files.join(' ')}" 26 | end 27 | 28 | desc 'Update documentation on website' 29 | task :sync_docs => 'rdoc' do 30 | `rsync -ave ssh doc/ dev@dev.thoughtbot.com:/home/dev/www/dev.thoughtbot.com/shoulda` 31 | end 32 | 33 | desc 'Default: run tests.' 34 | task :default => ['test'] 35 | 36 | Dir['tasks/*.rake'].each do |f| 37 | load f 38 | end 39 | 40 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/bin/convert_to_should_syntax: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | require 'tmpdir' 4 | 5 | TMP = Dir::tmpdir 6 | 7 | def usage(msg = nil) 8 | puts "Error: #{msg}" if msg 9 | puts if msg 10 | puts "Usage: #{File.basename(__FILE__)} normal_test_file.rb" 11 | puts 12 | puts "Will convert an existing test file with names like " 13 | puts 14 | puts " def test_should_do_stuff" 15 | puts " ..." 16 | puts " end" 17 | puts 18 | puts "to one using the new syntax: " 19 | puts 20 | puts " should \"be super cool\" do" 21 | puts " ..." 22 | puts " end" 23 | puts 24 | puts "A copy of the old file will be left under #{TMP} in case\nthis script just seriously screws up" 25 | puts 26 | exit (msg ? 2 : 0) 27 | end 28 | 29 | usage("Wrong number of arguments.") unless ARGV.size == 1 30 | usage("Temp directory '#{TMP}' is not valid. Set TMPDIR environment variable to a writeable directory.") unless File.directory?(TMP) && File.writable?(TMP) 31 | 32 | file = ARGV.shift 33 | tmpfile = File.join(TMP, File.basename(file)) 34 | usage("File '#{file}' doesn't exist") unless File.exists?(file) 35 | 36 | FileUtils.cp(file, tmpfile) 37 | contents = File.read(tmpfile) 38 | contents.gsub!(/def test_should_(\S+)/) {|line| "should \"#{$1.tr('_', ' ')}\" do"} 39 | contents.gsub!(/def test_(\S+)/) {|line| "should \"RENAME ME: test #{$1.tr('_', ' ')}\" do"} 40 | File.open(file, 'w') { |f| f.write(contents) } 41 | 42 | puts "File '#{file}' has been converted to 'should' syntax. Old version has been stored in '#{tmpfile}'" 43 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/init.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'active_support' 3 | require 'shoulda' 4 | 5 | if defined?(RAILS_ROOT) 6 | # load in the 3rd party macros from vendorized plugins and gems 7 | Dir[File.join(RAILS_ROOT, "vendor", "{plugin,gem}", "*", "shoulda_macros", "*.rb")].each do |macro_file_path| 8 | require macro_file_path 9 | end 10 | 11 | # load in the local application specific macros 12 | Dir[File.join(RAILS_ROOT, "test", "shoulda_macros", "*.rb")].each do |macro_file_path| 13 | require macro_file_path 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/lib/shoulda.rb: -------------------------------------------------------------------------------- 1 | require 'shoulda/gem/shoulda' 2 | require 'shoulda/private_helpers' 3 | require 'shoulda/general' 4 | require 'shoulda/active_record_helpers' 5 | require 'shoulda/controller_tests/controller_tests.rb' 6 | require 'yaml' 7 | 8 | shoulda_options = {} 9 | 10 | possible_config_paths = [] 11 | possible_config_paths << File.join(ENV["HOME"], ".shoulda.conf") if ENV["HOME"] 12 | possible_config_paths << "shoulda.conf" 13 | possible_config_paths << File.join("test", "shoulda.conf") 14 | possible_config_paths << File.join(RAILS_ROOT, "test", "shoulda.conf") if defined?(RAILS_ROOT) 15 | 16 | possible_config_paths.each do |config_file| 17 | if File.exists? config_file 18 | shoulda_options = YAML.load_file(config_file).symbolize_keys 19 | break 20 | end 21 | end 22 | 23 | require 'shoulda/color' if shoulda_options[:color] 24 | 25 | module Test # :nodoc: all 26 | module Unit 27 | class TestCase 28 | 29 | include ThoughtBot::Shoulda::General 30 | include ThoughtBot::Shoulda::Controller 31 | 32 | extend ThoughtBot::Shoulda::ActiveRecord 33 | end 34 | end 35 | end 36 | 37 | module ActionController #:nodoc: all 38 | module Integration 39 | class Session 40 | include ThoughtBot::Shoulda::General 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/lib/shoulda/color.rb: -------------------------------------------------------------------------------- 1 | require 'test/unit/ui/console/testrunner' 2 | 3 | # Completely stolen from redgreen gem 4 | # 5 | # Adds colored output to your tests. Specify color: true in 6 | # your ~/.shoulda.conf file to enable. 7 | # 8 | # *Bug*: for some reason, this adds another line of output to the end of 9 | # every rake task, as though there was another (empty) set of tests. 10 | # A fix would be most welcome. 11 | # 12 | module ThoughtBot::Shoulda::Color 13 | COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33 } # :nodoc: 14 | def self.method_missing(color_name, *args) # :nodoc: 15 | color(color_name) + args.first + color(:clear) 16 | end 17 | def self.color(color) # :nodoc: 18 | "\e[#{COLORS[color.to_sym]}m" 19 | end 20 | end 21 | 22 | module Test # :nodoc: 23 | module Unit # :nodoc: 24 | class TestResult # :nodoc: 25 | alias :old_to_s :to_s 26 | def to_s 27 | if old_to_s =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/ 28 | ThoughtBot::Shoulda::Color.send($1.to_i != 0 || $2.to_i != 0 ? :red : :green, $&) 29 | end 30 | end 31 | end 32 | 33 | class AutoRunner # :nodoc: 34 | alias :old_initialize :initialize 35 | def initialize(standalone) 36 | old_initialize(standalone) 37 | @runner = proc do |r| 38 | Test::Unit::UI::Console::RedGreenTestRunner 39 | end 40 | end 41 | end 42 | 43 | class Failure # :nodoc: 44 | alias :old_long_display :long_display 45 | def long_display 46 | # old_long_display.sub('Failure', ThoughtBot::Shoulda::Color.red('Failure')) 47 | ThoughtBot::Shoulda::Color.red(old_long_display) 48 | end 49 | end 50 | 51 | class Error # :nodoc: 52 | alias :old_long_display :long_display 53 | def long_display 54 | # old_long_display.sub('Error', ThoughtBot::Shoulda::Color.yellow('Error')) 55 | ThoughtBot::Shoulda::Color.yellow(old_long_display) 56 | end 57 | end 58 | 59 | module UI # :nodoc: 60 | module Console # :nodoc: 61 | class RedGreenTestRunner < Test::Unit::UI::Console::TestRunner # :nodoc: 62 | def output_single(something, level=NORMAL) 63 | return unless (output?(level)) 64 | something = case something 65 | when '.' then ThoughtBot::Shoulda::Color.green('.') 66 | when 'F' then ThoughtBot::Shoulda::Color.red("F") 67 | when 'E' then ThoughtBot::Shoulda::Color.yellow("E") 68 | else something 69 | end 70 | @io.write(something) 71 | @io.flush 72 | end 73 | end 74 | end 75 | end 76 | end 77 | end 78 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/lib/shoulda/gem/proc_extensions.rb: -------------------------------------------------------------------------------- 1 | # Stolen straight from ActiveSupport 2 | 3 | class Proc #:nodoc: 4 | def bind(object) 5 | block, time = self, Time.now 6 | (class << object; self end).class_eval do 7 | method_name = "__bind_#{time.to_i}_#{time.usec}" 8 | define_method(method_name, &block) 9 | method = instance_method(method_name) 10 | remove_method(method_name) 11 | method 12 | end.bind(object) 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/lib/shoulda/private_helpers.rb: -------------------------------------------------------------------------------- 1 | module ThoughtBot # :nodoc: 2 | module Shoulda # :nodoc: 3 | module Private # :nodoc: 4 | # Returns the values for the entries in the args hash who's keys are listed in the wanted array. 5 | # Will raise if there are keys in the args hash that aren't listed. 6 | def get_options!(args, *wanted) 7 | ret = [] 8 | opts = (args.last.is_a?(Hash) ? args.pop : {}) 9 | wanted.each {|w| ret << opts.delete(w)} 10 | raise ArgumentError, "Unsupported options given: #{opts.keys.join(', ')}" unless opts.keys.empty? 11 | return *ret 12 | end 13 | 14 | # Returns the model class constant, as determined by the test class name. 15 | # 16 | # class TestUser; model_class; end => User 17 | def model_class 18 | self.name.gsub(/Test$/, '').constantize 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/tasks/list_tests.rake: -------------------------------------------------------------------------------- 1 | namespace :shoulda do 2 | desc "List the names of the test methods in a specification like format" 3 | task :list do 4 | 5 | require 'test/unit' 6 | require 'rubygems' 7 | require 'active_support' 8 | 9 | # bug in test unit. Set to true to stop from running. 10 | Test::Unit.run = true 11 | 12 | test_files = Dir.glob(File.join('test', '**', '*_test.rb')) 13 | test_files.each do |file| 14 | load file 15 | klass = File.basename(file, '.rb').classify.constantize 16 | 17 | puts klass.name.gsub('Test', '') 18 | 19 | test_methods = klass.instance_methods.grep(/^test/).map {|s| s.gsub(/^test: /, '')}.sort 20 | test_methods.each {|m| puts " " + m } 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/tasks/yaml_to_shoulda.rake: -------------------------------------------------------------------------------- 1 | namespace :shoulda do 2 | # From http://blog.internautdesign.com/2007/11/2/a-yaml_to_shoulda-rake-task 3 | # David.Lowenfels@gmail.com 4 | desc "Converts a YAML file (FILE=./path/to/yaml) into a Shoulda skeleton" 5 | task :from_yaml do 6 | require 'yaml' 7 | 8 | def yaml_to_context(hash, indent = 0) 9 | indent1 = ' ' * indent 10 | indent2 = ' ' * (indent + 1) 11 | hash.each_pair do |context, shoulds| 12 | puts indent1 + "context \"#{context}\" do" 13 | puts 14 | shoulds.each do |should| 15 | yaml_to_context( should, indent + 1 ) and next if should.is_a?( Hash ) 16 | puts indent2 + "should_eventually \"" + should.gsub(/^should +/,'') + "\" do" 17 | puts indent2 + "end" 18 | puts 19 | end 20 | puts indent1 + "end" 21 | end 22 | end 23 | 24 | puts("Please pass in a FILE argument.") and exit unless ENV['FILE'] 25 | 26 | yaml_to_context( YAML.load_file( ENV['FILE'] ) ) 27 | end 28 | end -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/README: -------------------------------------------------------------------------------- 1 | The Shoulda test suite (in particular - the tests that test shoulda) 2 | 3 | Quick overview: 4 | 5 | The test directory contains the following files and subdirectories: 6 | 7 | * rails_root - contains the stripped down rails application that the tests run against. The rails root contains: 8 | ** the models, controllers, and views defined under app/ 9 | ** the sqlite3.rb environment file 10 | ** a migration file for each model 11 | ** a shoulda initializer that simulates loading the plugin but without relying on vendor/plugins 12 | * fixtures - contain the sample DB data for each model 13 | * functional - controller tests for each of the controllers under rails_root/app 14 | * unit - model tests for each of the models under rails_root/app 15 | * other - tests for the shoulda contexts, should statements, and assertions 16 | * test_helper.rb - responsible for initializing the test environment 17 | ** sets the rails_env to sqlite3 18 | ** sets the rails_root 19 | ** runs all the migrations against the in-memory sqlite3 db 20 | ** adds some magic to load the right fixture files 21 | 22 | In order to add a new model (or controller) to the test suite: 23 | 24 | * add that model to rails_root/app/models 25 | * add a migration for that model 26 | * add a fixture file 27 | * add a test for that file under test/units 28 | 29 | Dependencies: 30 | 31 | * Rails gem installed in the host system 32 | * A working sqlite3 installation. 33 | 34 | If you have problems running these tests, please notify the mailing list: shoulda@googlegroups.com 35 | 36 | - Tammer Saleh 37 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/fixtures/addresses.yml: -------------------------------------------------------------------------------- 1 | first: 2 | title: Home 3 | addressable: first (User) 4 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/fixtures/posts.yml: -------------------------------------------------------------------------------- 1 | first: 2 | id: 1 3 | title: My Cute Kitten! 4 | body: This is totally a cute kitten 5 | user_id: 1 6 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/fixtures/products.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/shoulda/test/fixtures/products.yml -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/fixtures/taggings.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/shoulda/test/fixtures/taggings.yml -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/fixtures/tags.yml: -------------------------------------------------------------------------------- 1 | first: 2 | id: 1 3 | name: Stuff 4 | second: 5 | id: 2 6 | name: Rails 7 | third: 8 | id: 3 9 | name: Nothing -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/fixtures/users.yml: -------------------------------------------------------------------------------- 1 | first: 2 | id: 1 3 | name: Some dude 4 | age: 2 5 | email: none@none.com 6 | ssn: 123456789 7 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/functional/posts_controller_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | require 'posts_controller' 3 | 4 | # Re-raise errors caught by the controller. 5 | class PostsController; def rescue_action(e) raise e end; end 6 | 7 | class PostsControllerTest < Test::Unit::TestCase 8 | load_all_fixtures 9 | 10 | def setup 11 | @controller = PostsController.new 12 | @request = ActionController::TestRequest.new 13 | @response = ActionController::TestResponse.new 14 | @post = Post.find(:first) 15 | end 16 | 17 | context "The public" do 18 | setup do 19 | @request.session[:logged_in] = false 20 | end 21 | 22 | should_be_restful do |resource| 23 | resource.parent = :user 24 | 25 | resource.denied.actions = [:index, :show, :edit, :new, :create, :update, :destroy] 26 | resource.denied.flash = /what/i 27 | resource.denied.redirect = '"/"' 28 | end 29 | end 30 | 31 | context "Logged in" do 32 | setup do 33 | @request.session[:logged_in] = true 34 | end 35 | 36 | should_be_restful do |resource| 37 | resource.parent = :user 38 | 39 | resource.create.params = { :title => "first post", :body => 'blah blah blah'} 40 | resource.update.params = { :title => "changed" } 41 | end 42 | 43 | context "viewing posts for a user" do 44 | setup do 45 | get :index, :user_id => users(:first) 46 | end 47 | should_respond_with :success 48 | should_assign_to :user, :posts 49 | should_not_assign_to :foo, :bar 50 | end 51 | end 52 | 53 | end 54 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/functional/users_controller_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | require 'users_controller' 3 | 4 | # Re-raise errors caught by the controller. 5 | class UsersController; def rescue_action(e) raise e end; end 6 | 7 | class UsersControllerTest < Test::Unit::TestCase 8 | load_all_fixtures 9 | 10 | def setup 11 | @controller = UsersController.new 12 | @request = ActionController::TestRequest.new 13 | @response = ActionController::TestResponse.new 14 | @user = User.find(:first) 15 | end 16 | 17 | should_be_restful do |resource| 18 | resource.identifier = :id 19 | resource.klass = User 20 | resource.object = :user 21 | resource.parent = [] 22 | resource.actions = [:index, :show, :new, :edit, :update, :create, :destroy] 23 | resource.formats = [:html, :xml] 24 | 25 | resource.create.params = { :name => "bob", :email => 'bob@bob.com', :age => 13, :ssn => "123456789"} 26 | resource.update.params = { :name => "sue" } 27 | 28 | resource.create.redirect = "user_url(@user)" 29 | resource.update.redirect = "user_url(@user)" 30 | resource.destroy.redirect = "users_url" 31 | 32 | resource.create.flash = /created/i 33 | resource.update.flash = /updated/i 34 | resource.destroy.flash = /removed/i 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/other/convert_to_should_syntax_test.rb: -------------------------------------------------------------------------------- 1 | require 'test/unit' 2 | 3 | class ConvertToShouldSyntaxTest < Test::Unit::TestCase # :nodoc: 4 | 5 | BEFORE_FIXTURE = <<-EOS 6 | class DummyTest < Test::Unit::TestCase 7 | 8 | should "Not change this_word_with_underscores" do 9 | end 10 | 11 | def test_should_be_working 12 | assert true 13 | end 14 | 15 | def test_some_cool_stuff 16 | assert true 17 | end 18 | 19 | def non_test_method 20 | end 21 | 22 | end 23 | EOS 24 | 25 | AFTER_FIXTURE = <<-EOS 26 | class DummyTest < Test::Unit::TestCase 27 | 28 | should "Not change this_word_with_underscores" do 29 | end 30 | 31 | should "be working" do 32 | assert true 33 | end 34 | 35 | should "RENAME ME: test some cool stuff" do 36 | assert true 37 | end 38 | 39 | def non_test_method 40 | end 41 | 42 | end 43 | EOS 44 | 45 | FIXTURE_PATH = "./convert_to_should_syntax_fixture.dat" 46 | 47 | RUBY = ENV['RUBY'] || 'ruby' 48 | 49 | def test_convert_to_should_syntax 50 | File.open(FIXTURE_PATH, "w") {|f| f.write(BEFORE_FIXTURE)} 51 | cmd = "#{RUBY} #{File.join(File.dirname(__FILE__), '../../bin/convert_to_should_syntax')} #{FIXTURE_PATH}" 52 | output = `#{cmd}` 53 | File.unlink($1) if output.match(/has been stored in '([^']+)/) 54 | assert_match(/has been converted/, output) 55 | result = IO.read(FIXTURE_PATH) 56 | assert_equal result, AFTER_FIXTURE 57 | end 58 | 59 | def teardown 60 | File.unlink(FIXTURE_PATH) 61 | end 62 | 63 | end 64 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/other/private_helpers_test.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'test_helper') 2 | 3 | class PrivateHelpersTest < Test::Unit::TestCase # :nodoc: 4 | include ThoughtBot::Shoulda::ActiveRecord 5 | context "get_options!" do 6 | should "remove opts from args" do 7 | args = [:a, :b, {}] 8 | get_options!(args) 9 | assert_equal [:a, :b], args 10 | end 11 | 12 | should "return wanted opts in order" do 13 | args = [{:one => 1, :two => 2}] 14 | one, two = get_options!(args, :one, :two) 15 | assert_equal 1, one 16 | assert_equal 2, two 17 | end 18 | 19 | should "raise ArgumentError if given unwanted option" do 20 | args = [{:one => 1, :two => 2}] 21 | assert_raises ArgumentError do 22 | get_options!(args, :one) 23 | end 24 | end 25 | end 26 | 27 | class ::SomeModel; end 28 | context "model_class" do 29 | should "sniff the class constant from the test class" do 30 | self.expects(:name).returns("SomeModelTest") 31 | assert_equal SomeModel, model_class 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/controllers/application.rb: -------------------------------------------------------------------------------- 1 | # Filters added to this controller apply to all controllers in the application. 2 | # Likewise, all the methods added will be available for all controllers. 3 | 4 | class ApplicationController < ActionController::Base 5 | # Pick a unique cookie name to distinguish our session data from others' 6 | session :session_key => '_rails_root_session_id' 7 | 8 | def ensure_logged_in 9 | unless session[:logged_in] 10 | respond_to do |accepts| 11 | accepts.html do 12 | flash[:error] = 'What do you think you\'re doing?' 13 | redirect_to '/' 14 | end 15 | accepts.xml do 16 | headers["Status"] = "Unauthorized" 17 | headers["WWW-Authenticate"] = %(Basic realm="Web Password") 18 | render :text => "Couldn't authenticate you", :status => '401 Unauthorized' 19 | end 20 | end 21 | return false 22 | end 23 | return true 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/controllers/posts_controller.rb: -------------------------------------------------------------------------------- 1 | class PostsController < ApplicationController 2 | before_filter :ensure_logged_in 3 | before_filter :load_user 4 | 5 | def index 6 | @posts = @user.posts 7 | 8 | respond_to do |format| 9 | format.html # index.rhtml 10 | format.xml { render :xml => @posts.to_xml } 11 | end 12 | end 13 | 14 | def show 15 | @post = @user.posts.find(params[:id]) 16 | 17 | respond_to do |format| 18 | format.html # show.rhtml 19 | format.xml { render :xml => @post.to_xml } 20 | end 21 | end 22 | 23 | def new 24 | @post = @user.posts.build 25 | end 26 | 27 | def edit 28 | @post = @user.posts.find(params[:id]) 29 | end 30 | 31 | def create 32 | @post = @user.posts.build(params[:post]) 33 | 34 | respond_to do |format| 35 | if @post.save 36 | flash[:notice] = 'Post was successfully created.' 37 | format.html { redirect_to user_post_url(@post.user, @post) } 38 | format.xml { head :created, :location => user_post_url(@post.user, @post) } 39 | else 40 | format.html { render :action => "new" } 41 | format.xml { render :xml => @post.errors.to_xml } 42 | end 43 | end 44 | end 45 | 46 | def update 47 | @post = @user.posts.find(params[:id]) 48 | 49 | respond_to do |format| 50 | if @post.update_attributes(params[:post]) 51 | flash[:notice] = 'Post was successfully updated.' 52 | format.html { redirect_to user_post_url(@post.user, @post) } 53 | format.xml { head :ok } 54 | else 55 | format.html { render :action => "edit" } 56 | format.xml { render :xml => @post.errors.to_xml } 57 | end 58 | end 59 | end 60 | 61 | def destroy 62 | @post = @user.posts.find(params[:id]) 63 | @post.destroy 64 | 65 | flash[:notice] = "Post was removed" 66 | 67 | respond_to do |format| 68 | format.html { redirect_to user_posts_url(@post.user) } 69 | format.xml { head :ok } 70 | end 71 | end 72 | 73 | private 74 | 75 | def load_user 76 | @user = User.find(params[:user_id]) 77 | end 78 | end 79 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/controllers/users_controller.rb: -------------------------------------------------------------------------------- 1 | class UsersController < ApplicationController 2 | # GET /users 3 | # GET /users.xml 4 | def index 5 | @users = User.find(:all) 6 | 7 | respond_to do |format| 8 | format.html # index.rhtml 9 | format.xml { render :xml => @users.to_xml } 10 | end 11 | end 12 | 13 | # GET /users/1 14 | # GET /users/1.xml 15 | def show 16 | @user = User.find(params[:id]) 17 | 18 | respond_to do |format| 19 | format.html # show.rhtml 20 | format.xml { render :xml => @user.to_xml } 21 | end 22 | end 23 | 24 | # GET /users/new 25 | def new 26 | @user = User.new 27 | end 28 | 29 | # GET /users/1;edit 30 | def edit 31 | @user = User.find(params[:id]) 32 | end 33 | 34 | # POST /users 35 | # POST /users.xml 36 | def create 37 | @user = User.new(params[:user]) 38 | 39 | respond_to do |format| 40 | if @user.save 41 | flash[:notice] = 'User was successfully created.' 42 | format.html { redirect_to user_url(@user) } 43 | format.xml { head :created, :location => user_url(@user) } 44 | else 45 | format.html { render :action => "new" } 46 | format.xml { render :xml => @user.errors.to_xml } 47 | end 48 | end 49 | end 50 | 51 | # PUT /users/1 52 | # PUT /users/1.xml 53 | def update 54 | @user = User.find(params[:id]) 55 | 56 | respond_to do |format| 57 | if @user.update_attributes(params[:user]) 58 | flash[:notice] = 'User was successfully updated.' 59 | format.html { redirect_to user_url(@user) } 60 | format.xml { head :ok } 61 | else 62 | format.html { render :action => "edit" } 63 | format.xml { render :xml => @user.errors.to_xml } 64 | end 65 | end 66 | end 67 | 68 | # DELETE /users/1 69 | # DELETE /users/1.xml 70 | def destroy 71 | @user = User.find(params[:id]) 72 | @user.destroy 73 | 74 | flash[:notice] = "User was removed" 75 | 76 | respond_to do |format| 77 | format.html { redirect_to users_url } 78 | format.xml { head :ok } 79 | end 80 | end 81 | end 82 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | # Methods added to this helper will be available to all templates in the application. 2 | module ApplicationHelper 3 | end 4 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/helpers/posts_helper.rb: -------------------------------------------------------------------------------- 1 | module PostsHelper 2 | end 3 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/helpers/users_helper.rb: -------------------------------------------------------------------------------- 1 | module UsersHelper 2 | end 3 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/models/address.rb: -------------------------------------------------------------------------------- 1 | class Address < ActiveRecord::Base 2 | belongs_to :addressable, :polymorphic => true 3 | validates_uniqueness_of :title, :scope => [:addressable_type, :addressable_id] 4 | 5 | validates_length_of :zip, :minimum => 5 6 | validates_numericality_of :zip 7 | end 8 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/models/dog.rb: -------------------------------------------------------------------------------- 1 | class Dog < ActiveRecord::Base 2 | belongs_to :user, :foreign_key => :owner_id 3 | has_and_belongs_to_many :fleas 4 | end 5 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/models/flea.rb: -------------------------------------------------------------------------------- 1 | class Flea < ActiveRecord::Base 2 | has_and_belongs_to_many :dogs 3 | end 4 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/models/post.rb: -------------------------------------------------------------------------------- 1 | class Post < ActiveRecord::Base 2 | belongs_to :user 3 | belongs_to :owner, :foreign_key => :user_id, :class_name => 'User' 4 | has_many :taggings 5 | has_many :tags, :through => :taggings 6 | has_many :through_tags, :through => :taggings, :source => :tags 7 | 8 | validates_uniqueness_of :title 9 | validates_presence_of :title 10 | validates_presence_of :body, :message => 'Seriously... wtf' 11 | validates_numericality_of :user_id 12 | end 13 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/models/product.rb: -------------------------------------------------------------------------------- 1 | class Product < ActiveRecord::Base 2 | validates_presence_of :title 3 | 4 | validates_inclusion_of :price, :in => 0..99, :unless => :tangible 5 | validates_format_of :size, :with => /^\d+\D+$/, :unless => :tangible 6 | 7 | validates_presence_of :price, :if => :tangible 8 | validates_inclusion_of :price, :in => 1..9999, :if => :tangible 9 | validates_inclusion_of :weight, :in => 1..100, :if => :tangible 10 | validates_format_of :size, :with => /.+x.+x.+/, :if => :tangible 11 | validates_length_of :size, :in => 5..20, :if => :tangible 12 | end 13 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/models/tag.rb: -------------------------------------------------------------------------------- 1 | class Tag < ActiveRecord::Base 2 | has_many :taggings, :dependent => :destroy 3 | has_many :posts, :through => :taggings 4 | 5 | validates_length_of :name, :minimum => 2 6 | 7 | attr_accessible :name 8 | end 9 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/models/tagging.rb: -------------------------------------------------------------------------------- 1 | class Tagging < ActiveRecord::Base 2 | belongs_to :post 3 | belongs_to :tag 4 | end 5 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/models/user.rb: -------------------------------------------------------------------------------- 1 | class User < ActiveRecord::Base 2 | has_many :posts 3 | has_many :dogs, :foreign_key => :owner_id 4 | 5 | has_one :address, :as => :addressable 6 | 7 | named_scope :old, :conditions => "age > 50" 8 | named_scope :eighteen, :conditions => { :age => 18 } 9 | named_scope :recent, lambda {|count| { :limit => count } } 10 | 11 | def self.recent_via_method(count) 12 | scoped(:limit => count) 13 | end 14 | 15 | attr_protected :password 16 | attr_readonly :name 17 | 18 | validates_format_of :email, :with => /\w*@\w*.com/ 19 | validates_length_of :email, :in => 1..100 20 | validates_inclusion_of :age, :in => 1..100 21 | validates_acceptance_of :eula 22 | validates_uniqueness_of :email, :scope => :name 23 | validates_length_of :ssn, :is => 9, :message => "Social Security Number is not the right length" 24 | validates_numericality_of :ssn 25 | end 26 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/layouts/posts.rhtml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | Posts: <%= controller.action_name %> 8 | <%= stylesheet_link_tag 'scaffold' %> 9 | 10 | 11 | 12 |

<%= flash[:notice] %>

13 | 14 | <%= yield %> 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/layouts/users.rhtml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | Users: <%= controller.action_name %> 8 | <%= stylesheet_link_tag 'scaffold' %> 9 | 10 | 11 | 12 |

<%= flash[:notice] %>

13 | 14 | <%= yield %> 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/posts/edit.rhtml: -------------------------------------------------------------------------------- 1 |

Editing post

2 | 3 | <%= error_messages_for :post %> 4 | 5 | <% form_for(:post, :url => user_post_path(@post.user, @post), :html => { :method => :put }) do |f| %> 6 |

7 | User
8 | <%= f.text_field :user_id %> 9 |

10 | 11 |

12 | Title
13 | <%= f.text_field :title %> 14 |

15 | 16 |

17 | Body
18 | <%= f.text_area :body %> 19 |

20 | 21 |

22 | <%= submit_tag "Update" %> 23 |

24 | <% end %> 25 | 26 | <%= link_to 'Show', user_post_path(@post.user, @post) %> | 27 | <%= link_to 'Back', user_posts_path(@post.user) %> 28 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/posts/index.rhtml: -------------------------------------------------------------------------------- 1 |

Listing posts

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | <% for post in @posts %> 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | <% end %> 21 |
UserTitleBody
<%=h post.user_id %><%=h post.title %><%=h post.body %><%= link_to 'Show', user_post_path(post.user, post) %><%= link_to 'Edit', edit_user_post_path(post.user, post) %><%= link_to 'Destroy', user_post_path(post.user, post), :confirm => 'Are you sure?', 18 | :method => :delete %>
22 | 23 |
24 | 25 | <%= link_to 'New post', new_user_post_path(post.user) %> 26 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/posts/new.rhtml: -------------------------------------------------------------------------------- 1 |

New post

2 | 3 | <%= error_messages_for :post %> 4 | 5 | <% form_for(:post, :url => user_posts_path(@user)) do |f| %> 6 |

7 | User
8 | <%= f.text_field :user_id %> 9 |

10 | 11 |

12 | Title
13 | <%= f.text_field :title %> 14 |

15 | 16 |

17 | Body
18 | <%= f.text_area :body %> 19 |

20 | 21 |

22 | <%= submit_tag "Create" %> 23 |

24 | <% end %> 25 | 26 | <%= link_to 'Back', user_posts_path(@user) %> 27 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/posts/show.rhtml: -------------------------------------------------------------------------------- 1 |

2 | User: 3 | <%=h @post.user_id %> 4 |

5 | 6 |

7 | Title: 8 | <%=h @post.title %> 9 |

10 | 11 |

12 | Body: 13 | <%=h @post.body %> 14 |

15 | 16 | 17 | <%= link_to 'Edit', edit_user_post_path(@post.user, @post) %> | 18 | <%= link_to 'Back', user_posts_path(@post.user) %> 19 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/users/edit.rhtml: -------------------------------------------------------------------------------- 1 |

Editing user

2 | 3 | <%= error_messages_for :user %> 4 | 5 | <% form_for(:user, :url => user_path(@user), :html => { :method => :put }) do |f| %> 6 |

7 | Email
8 | <%= f.text_field :email %> 9 |

10 | 11 |

12 | Age
13 | <%= f.text_field :age %> 14 |

15 | 16 |

17 | <%= submit_tag "Update" %> 18 |

19 | <% end %> 20 | 21 | <%= link_to 'Show', user_path(@user) %> | 22 | <%= link_to 'Back', users_path %> -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/users/index.rhtml: -------------------------------------------------------------------------------- 1 |

Listing users

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <% for user in @users %> 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | <% end %> 18 |
EmailAge
<%=h user.email %><%=h user.age %><%= link_to 'Show', user_path(user) %><%= link_to 'Edit', edit_user_path(user) %><%= link_to 'Destroy', user_path(user), :confirm => 'Are you sure?', :method => :delete %>
19 | 20 |
21 | 22 | <%= link_to 'New user', new_user_path %> -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/users/new.rhtml: -------------------------------------------------------------------------------- 1 |

New user

2 | 3 | <%= error_messages_for :user %> 4 | 5 | <% form_for(:user, :url => users_path) do |f| %> 6 |

7 | Email
8 | <%= f.text_field :email %> 9 |

10 | 11 |

12 | Age
13 | <%= f.text_field :age %> 14 |

15 | 16 |

17 | <%= submit_tag "Create" %> 18 |

19 | <% end %> 20 | 21 | <%= link_to 'Back', users_path %> -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/app/views/users/show.rhtml: -------------------------------------------------------------------------------- 1 |

2 | Email: 3 | <%=h @user.email %> 4 |

5 | 6 |

7 | Age: 8 | <%=h @user.age %> 9 |

10 | 11 | 12 | <%= link_to 'Edit', edit_user_path(@user) %> | 13 | <%= link_to 'Back', users_path %> -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/boot.rb: -------------------------------------------------------------------------------- 1 | # Don't change this file! 2 | # Configure your app in config/environment.rb and config/environments/*.rb 3 | 4 | RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) 5 | 6 | module Rails 7 | class << self 8 | def boot! 9 | unless booted? 10 | preinitialize 11 | pick_boot.run 12 | end 13 | end 14 | 15 | def booted? 16 | defined? Rails::Initializer 17 | end 18 | 19 | def pick_boot 20 | (vendor_rails? ? VendorBoot : GemBoot).new 21 | end 22 | 23 | def vendor_rails? 24 | File.exist?("#{RAILS_ROOT}/vendor/rails") 25 | end 26 | 27 | def preinitialize 28 | load(preinitializer_path) if File.exist?(preinitializer_path) 29 | end 30 | 31 | def preinitializer_path 32 | "#{RAILS_ROOT}/config/preinitializer.rb" 33 | end 34 | end 35 | 36 | class Boot 37 | def run 38 | load_initializer 39 | Rails::Initializer.run(:set_load_path) 40 | end 41 | end 42 | 43 | class VendorBoot < Boot 44 | def load_initializer 45 | require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" 46 | Rails::Initializer.run(:install_gem_spec_stubs) 47 | end 48 | end 49 | 50 | class GemBoot < Boot 51 | def load_initializer 52 | self.class.load_rubygems 53 | load_rails_gem 54 | require 'initializer' 55 | end 56 | 57 | def load_rails_gem 58 | if version = self.class.gem_version 59 | gem 'rails', version 60 | else 61 | gem 'rails' 62 | end 63 | rescue Gem::LoadError => load_error 64 | $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.) 65 | exit 1 66 | end 67 | 68 | class << self 69 | def rubygems_version 70 | Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion 71 | end 72 | 73 | def gem_version 74 | if defined? RAILS_GEM_VERSION 75 | RAILS_GEM_VERSION 76 | elsif ENV.include?('RAILS_GEM_VERSION') 77 | ENV['RAILS_GEM_VERSION'] 78 | else 79 | parse_gem_version(read_environment_rb) 80 | end 81 | end 82 | 83 | def load_rubygems 84 | require 'rubygems' 85 | 86 | unless rubygems_version >= '0.9.4' 87 | $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.) 88 | exit 1 89 | end 90 | 91 | rescue LoadError 92 | $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org) 93 | exit 1 94 | end 95 | 96 | def parse_gem_version(text) 97 | $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ 98 | end 99 | 100 | private 101 | def read_environment_rb 102 | File.read("#{RAILS_ROOT}/config/environment.rb") 103 | end 104 | end 105 | end 106 | end 107 | 108 | # All that for this: 109 | Rails.boot! 110 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/database.yml: -------------------------------------------------------------------------------- 1 | sqlite3: 2 | :adapter: sqlite3 3 | # :dbfile: db/sqlite3.db 4 | :dbfile: ":memory:" 5 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Specifies gem version of Rails to use when vendor/rails is not present 2 | old_verbose, $VERBOSE = $VERBOSE, nil 3 | RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION 4 | $VERBOSE = old_verbose 5 | 6 | require File.join(File.dirname(__FILE__), 'boot') 7 | 8 | Rails::Initializer.run do |config| 9 | config.log_level = :debug 10 | config.cache_classes = false 11 | config.whiny_nils = true 12 | end 13 | 14 | # Dependencies.log_activity = true 15 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/environments/sqlite3.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/shoulda/test/rails_root/config/environments/sqlite3.rb -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/initializers/new_rails_defaults.rb: -------------------------------------------------------------------------------- 1 | # These settings change the behavior of Rails 2 apps and will be defaults 2 | # for Rails 3. You can remove this initializer when Rails 3 is released. 3 | 4 | # Include Active Record class name as root for JSON serialized output. 5 | ActiveRecord::Base.include_root_in_json = true 6 | 7 | # Store the full class name (including module namespace) in STI type column. 8 | ActiveRecord::Base.store_full_sti_class = true 9 | 10 | # Use ISO 8601 format for JSON serialized times and dates. 11 | ActiveSupport.use_standard_json_time_format = true 12 | 13 | # Don't escape HTML entities in JSON, leave that for the #json_escape helper. 14 | # if you're including raw json in an HTML page. 15 | ActiveSupport.escape_html_entities_in_json = false -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/initializers/shoulda.rb: -------------------------------------------------------------------------------- 1 | # This simulates loading the shoulda plugin, but without relying on 2 | # vendor/plugins 3 | 4 | shoulda_path = File.join(File.dirname(__FILE__), *%w(.. .. .. ..)) 5 | shoulda_lib_path = File.join(shoulda_path, "lib") 6 | 7 | $LOAD_PATH.unshift(shoulda_lib_path) 8 | load File.join(shoulda_path, "init.rb") 9 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/config/routes.rb: -------------------------------------------------------------------------------- 1 | ActionController::Routing::Routes.draw do |map| 2 | 3 | map.resources :posts 4 | map.resources :users, :has_many => :posts 5 | 6 | end 7 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/001_create_users.rb: -------------------------------------------------------------------------------- 1 | class CreateUsers < ActiveRecord::Migration 2 | def self.up 3 | create_table :users do |t| 4 | t.column :name, :string 5 | t.column :email, :string 6 | t.column :age, :integer 7 | t.column :ssn, :string 8 | end 9 | add_index :users, :email 10 | add_index :users, :name 11 | add_index :users, :age 12 | add_index :users, [:email, :name] 13 | end 14 | 15 | def self.down 16 | drop_table :users 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/002_create_posts.rb: -------------------------------------------------------------------------------- 1 | class CreatePosts < ActiveRecord::Migration 2 | def self.up 3 | create_table :posts do |t| 4 | t.column :user_id, :integer 5 | t.column :title, :string 6 | t.column :body, :text 7 | end 8 | end 9 | 10 | def self.down 11 | drop_table :posts 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/003_create_taggings.rb: -------------------------------------------------------------------------------- 1 | class CreateTaggings < ActiveRecord::Migration 2 | def self.up 3 | create_table :taggings do |t| 4 | t.column :post_id, :integer 5 | t.column :tag_id, :integer 6 | end 7 | end 8 | 9 | def self.down 10 | drop_table :taggings 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/004_create_tags.rb: -------------------------------------------------------------------------------- 1 | class CreateTags < ActiveRecord::Migration 2 | def self.up 3 | create_table :tags do |t| 4 | t.column :name, :string 5 | end 6 | end 7 | 8 | def self.down 9 | drop_table :tags 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/005_create_dogs.rb: -------------------------------------------------------------------------------- 1 | class CreateDogs < ActiveRecord::Migration 2 | def self.up 3 | create_table :dogs do |t| 4 | t.column :owner_id, :integer 5 | end 6 | end 7 | 8 | def self.down 9 | drop_table :dogs 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/006_create_addresses.rb: -------------------------------------------------------------------------------- 1 | class CreateAddresses < ActiveRecord::Migration 2 | def self.up 3 | create_table :addresses do |t| 4 | t.column :title, :string 5 | t.column :addressable_id, :integer 6 | t.column :addressable_type, :string 7 | t.column :zip, :string 8 | end 9 | end 10 | 11 | def self.down 12 | drop_table :addresses 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/007_create_fleas.rb: -------------------------------------------------------------------------------- 1 | class CreateFleas < ActiveRecord::Migration 2 | def self.up 3 | create_table :fleas do |t| 4 | t.string :name 5 | end 6 | end 7 | 8 | def self.down 9 | drop_table :fleas 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/008_create_dogs_fleas.rb: -------------------------------------------------------------------------------- 1 | class CreateDogsFleas < ActiveRecord::Migration 2 | def self.up 3 | create_table :dogs_fleas do |t| 4 | t.integer :dog_id 5 | t.integer :flea_id 6 | end 7 | end 8 | 9 | def self.down 10 | drop_table :dogs_fleas 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/migrate/009_create_products.rb: -------------------------------------------------------------------------------- 1 | class CreateProducts < ActiveRecord::Migration 2 | def self.up 3 | create_table :products do |t| 4 | t.string :title 5 | t.integer :price 6 | t.integer :weight 7 | t.string :size 8 | t.boolean :tangible 9 | 10 | t.timestamps 11 | end 12 | end 13 | 14 | def self.down 15 | drop_table :products 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/db/schema.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/shoulda/test/rails_root/db/schema.rb -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/shoulda/test/rails_root/log/.keep -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/public/.htaccess: -------------------------------------------------------------------------------- 1 | # General Apache options 2 | AddHandler fastcgi-script .fcgi 3 | AddHandler cgi-script .cgi 4 | Options +FollowSymLinks +ExecCGI 5 | 6 | # If you don't want Rails to look in certain directories, 7 | # use the following rewrite rules so that Apache won't rewrite certain requests 8 | # 9 | # Example: 10 | # RewriteCond %{REQUEST_URI} ^/notrails.* 11 | # RewriteRule .* - [L] 12 | 13 | # Redirect all requests not available on the filesystem to Rails 14 | # By default the cgi dispatcher is used which is very slow 15 | # 16 | # For better performance replace the dispatcher with the fastcgi one 17 | # 18 | # Example: 19 | # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] 20 | RewriteEngine On 21 | 22 | # If your Rails application is accessed via an Alias directive, 23 | # then you MUST also set the RewriteBase in this htaccess file. 24 | # 25 | # Example: 26 | # Alias /myrailsapp /path/to/myrailsapp/public 27 | # RewriteBase /myrailsapp 28 | 29 | RewriteRule ^$ index.html [QSA] 30 | RewriteRule ^([^.]+)$ $1.html [QSA] 31 | RewriteCond %{REQUEST_FILENAME} !-f 32 | RewriteRule ^(.*)$ dispatch.cgi [QSA,L] 33 | 34 | # In case Rails experiences terminal errors 35 | # Instead of displaying this message you can supply a file here which will be rendered instead 36 | # 37 | # Example: 38 | # ErrorDocument 500 /500.html 39 | 40 | ErrorDocument 500 "

Application error

Rails application failed to start properly" -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/public/404.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | The page you were looking for doesn't exist (404) 9 | 21 | 22 | 23 | 24 | 25 |
26 |

The page you were looking for doesn't exist.

27 |

You may have mistyped the address or the page may have moved.

28 |
29 | 30 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/public/422.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | The change you wanted was rejected (422) 9 | 21 | 22 | 23 | 24 | 25 |
26 |

The change you wanted was rejected.

27 |

Maybe you tried to change something you didn't have access to.

28 |
29 | 30 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/public/500.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | We're sorry, but something went wrong (500) 9 | 21 | 22 | 23 | 24 | 25 |
26 |

We're sorry, but something went wrong.

27 |

We've been notified about this issue and we'll take a look at it shortly.

28 |
29 | 30 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/script/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../config/boot' 3 | require 'commands/console' 4 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/script/generate: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.dirname(__FILE__) + '/../config/boot' 3 | require 'commands/generate' 4 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/rails_root/vendor/plugins/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sutto/rubyflow/c7b6f3ec7657abb0d0adfc120151effe7c818c07/vendor/plugins/shoulda/test/rails_root/vendor/plugins/.keep -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | require 'fileutils' 2 | # Load the environment 3 | ENV['RAILS_ENV'] = 'sqlite3' 4 | 5 | rails_root = File.dirname(__FILE__) + '/rails_root' 6 | 7 | require "#{rails_root}/config/environment.rb" 8 | 9 | # Load the testing framework 10 | require 'test_help' 11 | silence_warnings { RAILS_ENV = ENV['RAILS_ENV'] } 12 | 13 | # Run the migrations 14 | ActiveRecord::Migration.verbose = false 15 | ActiveRecord::Migrator.migrate("#{RAILS_ROOT}/db/migrate") 16 | 17 | # Setup the fixtures path 18 | Test::Unit::TestCase.fixture_path = File.join(File.dirname(__FILE__), "fixtures") 19 | 20 | class Test::Unit::TestCase #:nodoc: 21 | def create_fixtures(*table_names) 22 | if block_given? 23 | Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield } 24 | else 25 | Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) 26 | end 27 | end 28 | 29 | self.use_transactional_fixtures = false 30 | self.use_instantiated_fixtures = false 31 | end 32 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/unit/address_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class AddressTest < Test::Unit::TestCase 4 | load_all_fixtures 5 | should_belong_to :addressable 6 | should_require_unique_attributes :title, :scoped_to => [:addressable_id, :addressable_type] 7 | 8 | 9 | should_ensure_length_at_least :zip, 5 10 | should_only_allow_numeric_values_for :zip 11 | end 12 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/unit/dog_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class DogTest < Test::Unit::TestCase 4 | load_all_fixtures 5 | should_belong_to :user 6 | should_have_and_belong_to_many :fleas 7 | end 8 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/unit/flea_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class FleaTest < Test::Unit::TestCase 4 | load_all_fixtures 5 | should_have_and_belong_to_many :dogs 6 | end 7 | 8 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/unit/post_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class PostTest < Test::Unit::TestCase 4 | load_all_fixtures 5 | 6 | should_belong_to :user 7 | should_belong_to :owner 8 | should_have_many :tags, :through => :taggings 9 | should_have_many :through_tags, :through => :taggings 10 | 11 | should_require_unique_attributes :title 12 | should_require_attributes :body, :message => /wtf/ 13 | should_require_attributes :title 14 | should_only_allow_numeric_values_for :user_id 15 | end 16 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/unit/product_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class ProductTest < ActiveSupport::TestCase 4 | context "An intangible product" do 5 | setup do 6 | @product = Product.new(:tangible => false) 7 | end 8 | 9 | should_require_attributes :title 10 | should_not_allow_values_for :size, "22" 11 | should_allow_values_for :size, "22kb" 12 | should_ensure_value_in_range :price, 0..99 13 | end 14 | 15 | context "A tangible product" do 16 | setup do 17 | @product = Product.new(:tangible => true) 18 | end 19 | 20 | should_require_attributes :price 21 | should_ensure_value_in_range :price, 1..9999 22 | should_ensure_value_in_range :weight, 1..100 23 | should_not_allow_values_for :size, "22", "10x15" 24 | should_allow_values_for :size, "12x12x1" 25 | should_ensure_length_in_range :size, 5..20 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/unit/tag_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class TagTest < Test::Unit::TestCase 4 | load_all_fixtures 5 | 6 | should_have_many :taggings, :dependent => :destroy 7 | should_have_many :posts 8 | 9 | should_ensure_length_at_least :name, 2 10 | 11 | should_protect_attributes :secret 12 | end 13 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/unit/tagging_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class TaggingTest < Test::Unit::TestCase 4 | load_all_fixtures 5 | 6 | should_belong_to :post 7 | should_belong_to :tag 8 | end 9 | -------------------------------------------------------------------------------- /vendor/plugins/shoulda/test/unit/user_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/../test_helper' 2 | 3 | class UserTest < Test::Unit::TestCase 4 | load_all_fixtures 5 | 6 | should_have_many :posts 7 | should_have_many :dogs 8 | 9 | should_have_one :address 10 | 11 | should_have_indices :email, :name, [:email, :name] 12 | should_have_index :age 13 | 14 | should_have_named_scope :old, :conditions => "age > 50" 15 | should_have_named_scope :eighteen, :conditions => { :age => 18 } 16 | 17 | should_have_named_scope 'recent(5)', :limit => 5 18 | should_have_named_scope 'recent(1)', :limit => 1 19 | should_have_named_scope 'recent_via_method(7)', :limit => 7 20 | 21 | context "when given an instance variable" do 22 | setup { @count = 2 } 23 | should_have_named_scope 'recent(@count)', :limit => 2 24 | end 25 | 26 | should_not_allow_values_for :email, "blah", "b lah" 27 | should_allow_values_for :email, "a@b.com", "asdf@asdf.com" 28 | should_ensure_length_in_range :email, 1..100 29 | should_ensure_value_in_range :age, 1..100 30 | should_protect_attributes :password 31 | should_have_class_methods :find, :destroy 32 | should_have_instance_methods :email, :age, :email=, :valid? 33 | should_have_db_columns :name, :email, :age 34 | should_have_db_column :id, :type => "integer", :primary => true 35 | should_have_db_column :email, :type => "string", :default => nil, :precision => nil, :limit => 255, 36 | :null => true, :primary => false, :scale => nil, :sql_type => 'varchar(255)' 37 | should_require_acceptance_of :eula 38 | should_require_unique_attributes :email, :scoped_to => :name 39 | 40 | should_ensure_length_is :ssn, 9, :message => "Social Security Number is not the right length" 41 | should_only_allow_numeric_values_for :ssn 42 | 43 | should_have_readonly_attributes :name 44 | end 45 | --------------------------------------------------------------------------------