-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Survived driving day 2 enabled guard and other updates
- Loading branch information
1 parent
b558058
commit bcf5817
Showing
23 changed files
with
483 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# A sample Guardfile | ||
# More info at https://github.com/guard/guard#readme | ||
|
||
guard 'rspec', :version => 2 do | ||
watch(%r{^spec/.+_spec\.rb$}) | ||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } | ||
watch('spec/spec_helper.rb') { "spec" } | ||
|
||
# Rails example | ||
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } | ||
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } | ||
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } | ||
watch(%r{^spec/support/(.+)\.rb$}) { "spec" } | ||
watch('config/routes.rb') { "spec/routing" } | ||
watch('app/controllers/application_controller.rb') { "spec/controllers" } | ||
# Capybara request specs | ||
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" } | ||
end | ||
|
||
|
||
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do | ||
watch('config/application.rb') | ||
watch('config/environment.rb') | ||
watch(%r{^config/environments/.+\.rb$}) | ||
watch(%r{^config/initializers/.+\.rb$}) | ||
watch('Gemfile') | ||
watch('Gemfile.lock') | ||
watch('spec/spec_helper.rb') { :rspec } | ||
watch('test/test_helper.rb') { :test_unit } | ||
watch(%r{features/support/}) { :cucumber } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the votes controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
class VotesController < ApplicationController | ||
# GET /votes | ||
# GET /votes.json | ||
def index | ||
@votes = Vote.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @votes } | ||
end | ||
end | ||
|
||
# GET /votes/1 | ||
# GET /votes/1.json | ||
def show | ||
@vote = Vote.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @vote } | ||
end | ||
end | ||
|
||
# GET /votes/new | ||
# GET /votes/new.json | ||
def new | ||
@vote = Vote.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @vote } | ||
end | ||
end | ||
|
||
# GET /votes/1/edit | ||
def edit | ||
@vote = Vote.find(params[:id]) | ||
end | ||
|
||
# POST /votes | ||
# POST /votes.json | ||
def create | ||
@vote = Vote.new(params[:vote]) | ||
|
||
respond_to do |format| | ||
if @vote.save | ||
format.html { redirect_to @vote, notice: 'Vote was successfully created.' } | ||
format.json { render json: @vote, status: :created, location: @vote } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @vote.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /votes/1 | ||
# PUT /votes/1.json | ||
def update | ||
@vote = Vote.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @vote.update_attributes(params[:vote]) | ||
format.html { redirect_to @vote, notice: 'Vote was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @vote.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /votes/1 | ||
# DELETE /votes/1.json | ||
def destroy | ||
@vote = Vote.find(params[:id]) | ||
@vote.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to votes_url } | ||
format.json { head :no_content } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module VotesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Vote < ActiveRecord::Base | ||
attr_accessible :story_id, :twitter_handle, :value | ||
validates_presence_of :twitter_handle | ||
validates_presence_of :story_id | ||
validates_presence_of :value | ||
validates_format_of :twitter_handle, with: /\A@\w+\Z/ | ||
validates_inclusion_of :value, in: [-1,1] | ||
belongs_to :story | ||
validates_uniqueness_of :twitter_handle, scope: :story_id | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<%= form_for(@vote) do |f| %> | ||
<% if @vote.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@vote.errors.count, "error") %> prohibited this vote from being saved:</h2> | ||
|
||
<ul> | ||
<% @vote.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :twitter_handle %><br /> | ||
<%= f.text_field :twitter_handle %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :value %><br /> | ||
<%= f.number_field :value %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :story_id %><br /> | ||
<%= f.number_field :story_id %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing vote</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Show', @vote %> | | ||
<%= link_to 'Back', votes_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<h1>Listing votes</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Twitter handle</th> | ||
<th>Value</th> | ||
<th>Story</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
|
||
<% @votes.each do |vote| %> | ||
<tr> | ||
<td><%= vote.twitter_handle %></td> | ||
<td><%= vote.value %></td> | ||
<td><%= vote.story_id %></td> | ||
<td><%= link_to 'Show', vote %></td> | ||
<td><%= link_to 'Edit', edit_vote_path(vote) %></td> | ||
<td><%= link_to 'Destroy', vote, confirm: 'Are you sure?', method: :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New Vote', new_vote_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New vote</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Back', votes_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<b>Twitter handle:</b> | ||
<%= @vote.twitter_handle %> | ||
</p> | ||
|
||
<p> | ||
<b>Value:</b> | ||
<%= @vote.value %> | ||
</p> | ||
|
||
<p> | ||
<b>Story:</b> | ||
<%= @vote.story_id %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_vote_path(@vote) %> | | ||
<%= link_to 'Back', votes_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.