Skip to content
This repository was archived by the owner on Mar 13, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source "http://rubygems.org"

gem "rails", "3.0.10"
gem "mysql", "2.8.1"
gem "mysql2", "0.2.13"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using rbenv. Only got working (got all tests passing) with mysql2 for some reason. Assume all changes to Gemfile should be ignored if you have a different, rvm setup that's already working for you.

gem "simple_form", "1.5.0"
gem "omniauth", "0.2.6"
gem "paper_trail", "1.6.4"
Expand All @@ -12,7 +12,7 @@ group :test do
gem "factory_girl_rails", "1.0"
gem "shoulda", "2.11.3"
gem "capybara", "0.3.9"
gem "database_cleaner", "0.5.2"
gem "database_cleaner", "0.6.0"
gem "mocha", "0.9.8", :require => false
gem "faker", "0.9.5"
gem "timecop", "0.3.5"
Expand All @@ -22,3 +22,5 @@ group :test do
gem "launchy"
gem "escape_utils", "0.1.9"
end

gem "rake", "0.8.7"
49 changes: 23 additions & 26 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,15 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (>= 0.0.3)
childprocess (0.0.9)
ffi (~> 0.6.3)
columnize (0.3.1)
configuration (1.1.0)
culerity (0.2.12)
database_cleaner (0.5.2)
childprocess (0.2.2)
ffi (~> 1.0.6)
columnize (0.3.4)
culerity (0.2.15)
database_cleaner (0.6.0)
erubis (2.6.6)
abstract (>= 1.0.0)
escape_utils (0.1.9)
factory_girl (1.3.2)
factory_girl (1.3.3)
factory_girl_rails (1.0)
factory_girl (~> 1.3)
rails (>= 3.0.0.beta4)
Expand All @@ -60,15 +59,12 @@ GEM
rack (< 2, >= 1.1.0)
faraday_middleware (0.6.5)
faraday (~> 0.6.0)
ffi (0.6.3)
rake (>= 0.8.7)
ffi (1.0.9)
hashie (1.0.0)
i18n (0.5.0)
json_pure (1.4.6)
launchy (0.3.7)
configuration (>= 0.0.5)
rake (>= 0.8.1)
linecache19 (0.5.11)
json_pure (1.6.1)
launchy (2.0.3)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mail (2.2.19)
activesupport (>= 2.3.6)
Expand All @@ -81,9 +77,9 @@ GEM
multi_json (1.0.3)
multi_xml (0.2.2)
multipart-post (1.1.3)
mysql (2.8.1)
mysql2 (0.2.13)
net-ldap (0.2.2)
nokogiri (1.4.3.1)
nokogiri (1.4.7)
oa-basic (0.2.6)
oa-core (= 0.2.6)
rest-client (~> 1.6.0)
Expand Down Expand Up @@ -126,7 +122,7 @@ GEM
activerecord (>= 2.3)
polyglot (0.3.2)
pyu-ruby-sasl (0.0.3.3)
rack (1.2.3)
rack (1.2.4)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-openid (1.3.1)
Expand All @@ -148,12 +144,12 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
rake (0.9.2)
rake (0.8.7)
rdoc (3.9.4)
redcarpet (2.0.0b5)
rest-client (1.6.7)
mime-types (>= 1.16)
ruby-debug-base19 (0.11.24)
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
Expand All @@ -164,13 +160,13 @@ GEM
ruby-openid (2.1.8)
ruby-openid-apps-discovery (1.2.0)
ruby-openid (>= 2.1.7)
ruby_core_source (0.1.4)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
rubyntlm (0.1.1)
rubyzip (0.9.4)
selenium-webdriver (0.0.29)
childprocess (>= 0.0.7)
ffi (~> 0.6.3)
selenium-webdriver (2.7.0)
childprocess (>= 0.2.1)
ffi (>= 1.0.7)
json_pure
rubyzip
shoulda (2.11.3)
Expand All @@ -190,23 +186,24 @@ GEM
multi_json (~> 1.0.0)
multi_xml (~> 0.2.0)
simple_oauth (~> 0.1.5)
tzinfo (0.3.29)
tzinfo (0.3.30)

PLATFORMS
ruby

DEPENDENCIES
capybara (= 0.3.9)
database_cleaner (= 0.5.2)
database_cleaner (= 0.6.0)
escape_utils (= 0.1.9)
factory_girl_rails (= 1.0)
faker (= 0.9.5)
launchy
mocha (= 0.9.8)
mysql (= 2.8.1)
mysql2 (= 0.2.13)
omniauth (= 0.2.6)
paper_trail (= 1.6.4)
rails (= 3.0.10)
rake (= 0.8.7)
redcarpet (~> 2.0.0b5)
ruby-debug19
shoulda (= 2.11.3)
Expand Down
10 changes: 9 additions & 1 deletion app/controllers/proposals_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'uri'

class ProposalsController < ApplicationController
before_filter :authenticate_user!, :except => [:index, :show]

Expand All @@ -18,6 +20,12 @@ def new
@proposal = Proposal.new
end

def moot
@proposal = Proposal.new
@proposal.title = URI.unescape params[:title]
render :new
end

def create
@proposal = current_user.proposals.new(params[:proposal])
if @proposal.save
Expand All @@ -36,7 +44,7 @@ def update
if @proposal.update_attributes(params[:proposal])
redirect_to proposal_path(@proposal)
else
render :edit
render :edit
end
end

Expand Down
9 changes: 9 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'redcarpet'
require 'uri'

module ApplicationHelper
def render_page_title
Expand Down Expand Up @@ -32,8 +33,16 @@ def avatar_url(user, bigger=false)
end
end

def wikiize(text)
names = {}
User.all.each {|user| names[user.name] = link_to(user.name, user) }
Proposal.all.each {|proposal| names[proposal.title] = link_to(proposal.title, proposal) }
text.gsub(/\[\[(.*?)\]\]/) {|s| names[$1] || link_to($1, {:controller => "proposals", :action => "moot", :title => URI.escape($1)}) }
end

def markdown(text)
if text
text = wikiize(text)
markdown_parser.render(text).html_safe
else
nil
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Vestibule::Application.routes.draw do
resources :users, :only => [:show, :edit, :update]
get "/proposals/moot"
resources :proposals, :except => [:destroy] do
resources :suggestions, :only => [:create]
member do
Expand Down
10 changes: 5 additions & 5 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Daley', :city => cities.first)

def user(name)
User.create!(:name => name, :twitter_nickname => name)
def user(name, nickname=nil)
User.create!(:name => name, :twitter_nickname => nickname || name)
end

def suggestions_for(proposal, suggestions)
Expand All @@ -19,10 +19,10 @@ def suggestions_for(proposal, suggestions)
end
end

alice = user("alice")
alice = user("Alice", "alice")
bob = user("bob")
charlie = user("charlie")
daniel = user("daniel")
charlie = user("Charlie Parker", "charlie")
daniel = user("Daniel Boone", "daniel")

a = alice.proposals.create :title => "Fake it till you make it", :description => <<-EOS
I've written a few things recently which work against 3rd party HTTP API's recently.
Expand Down
27 changes: 27 additions & 0 deletions test/unit/helpers/application_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,31 @@ class ApplicationHelperTest < ActionView::TestCase
end
end
end

context "wiki" do
context "for a single user" do
setup do
@user = Factory(:user, :twitter_nickname => "rdrake98", :name => "Richard Drake")
end

should "turn into link" do
assert_equal link_to("Richard Drake", "/users/rdrake98"), wikiize("[[Richard Drake]]")
end
end

context "for a single proposal" do
setup do
@user = Factory(:proposal, :title => "My One and Only")
end

should "turn into link" do
assert_equal link_to("My One and Only", "/proposals/1"), wikiize("[[My One and Only]]")
assert_equal link_to("Her Latest Idea", "/proposals/moot?title=Her%2520Latest%2520Idea"), wikiize("[[Her Latest Idea]]")
assert_equal(
"I prefer <a href=\"/proposals/moot?title=Her%2520Latest%2520Idea\">Her Latest Idea</a> to <a href=\"/proposals/1\">My One and Only</a>.",
wikiize("I prefer [[Her Latest Idea]] to [[My One and Only]].")
)
end
end
end
end