Permalink
Browse files

Added Robots

  • Loading branch information...
1 parent 7e26fb6 commit 48997c79c1ec45b6fb1f4702ad56355f856f82d3 Alex Berry committed Apr 9, 2012
Showing with 383 additions and 94 deletions.
  1. +1 −0 .rvmrc
  2. +9 −9 Gemfile.lock
  3. +4 −0 app/controllers/homepages_controller.rb
  4. +19 −0 app/controllers/robots_controller.rb
  5. +2 −0 app/models/robot.rb
  6. +1 −0 app/models/user.rb
  7. +21 −0 app/views/homepages/index.html.erb
  8. +9 −0 app/views/layouts/application.html.erb
  9. +0 −16 app/views/pages/homepage.html.erb
  10. +1 −0 app/views/robots/_robot.html.erb
  11. +4 −0 app/views/robots/edit.html.erb
  12. 0 app/views/robots/show.html.erb
  13. +2 −1 config/environments/development.rb
  14. +3 −0 config/environments/test.rb
  15. +2 −2 config/routes.rb
  16. +6 −0 db/migrate/20120407235044_add_users_to_robots.rb
  17. +4 −2 db/schema.rb
  18. +0 −14 features/account.feature
  19. +41 −0 features/clearance/visitor_resets_password.feature
  20. +26 −0 features/clearance/visitor_signs_in.feature
  21. +12 −0 features/clearance/visitor_signs_out.feature
  22. +17 −0 features/clearance/visitor_signs_up.feature
  23. +2 −1 features/homepage.feature
  24. +30 −0 features/robot.feature
  25. +0 −10 features/robot_new.feature
  26. +0 −24 features/step_definitions/account_steps.rb
  27. +122 −0 features/step_definitions/clearance/clearance_steps.rb
  28. +8 −0 features/step_definitions/homepage_steps.rb
  29. +0 −9 features/step_definitions/robot_new_steps.rb
  30. +26 −0 features/step_definitions/robot_steps.rb
  31. +2 −1 features/support/env.rb
  32. +2 −0 spec/factories/robot.rb
  33. +2 −3 spec/models/robot_spec.rb
  34. +3 −0 spec/models/user_spec.rb
  35. +1 −2 spec/spec_helper.rb
  36. +1 −0 spec/support/clearance.rb
View
@@ -0,0 +1 @@
+rvm use 1.9.3
View
@@ -41,7 +41,7 @@ GEM
xpath (~> 0.1.4)
childprocess (0.3.1)
ffi (~> 1.0.6)
- clearance (0.16.0)
+ clearance (0.16.1)
diesel (~> 0.1.5)
rails (>= 3.0)
cucumber (1.1.9)
@@ -61,16 +61,16 @@ GEM
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
- factory_girl (2.3.2)
- activesupport
- factory_girl_rails (1.4.0)
- factory_girl (~> 2.3.0)
+ factory_girl (3.1.0)
+ activesupport (>= 3.0.0)
+ factory_girl_rails (3.1.0)
+ factory_girl (~> 3.1.0)
railties (>= 3.0.0)
ffi (1.0.11)
flutie (1.3.3)
formtastic (2.1.1)
actionpack (~> 3.0)
- gherkin (2.9.1)
+ gherkin (2.9.3)
json (>= 1.4.6)
guard (1.0.1)
ffi (>= 0.5.0)
@@ -80,14 +80,14 @@ GEM
guard (>= 0.8.3)
guard-rspec (0.7.0)
guard (>= 0.10.0)
- guard-spork (0.5.2)
+ guard-spork (0.6.0)
guard (>= 0.10.0)
spork (>= 0.8.4)
high_voltage (1.1.1)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
- jquery-rails (2.0.1)
+ jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
json (1.6.6)
@@ -130,7 +130,7 @@ GEM
rspec-expectations (~> 2.9.0)
rspec-mocks (~> 2.9.0)
rspec-core (2.9.0)
- rspec-expectations (2.9.0)
+ rspec-expectations (2.9.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.9.0)
rspec-rails (2.9.0)
@@ -0,0 +1,4 @@
+class HomepagesController < ApplicationController
+ def index
+ end
+end
@@ -3,13 +3,32 @@ def new
@robot = Robot.new
end
+ def show
+ @robot = Robot.find(params[:id])
+ end
def create
@robot = Robot.new(params[:robot])
+ current_user.robots << @robot
if @robot.save
redirect_to root_path
else
render :new
end
+ end
+
+ def edit
+ @robot = Robot.find(params[:id])
+ end
+
+ def update
+ @robot = Robot.find(params[:id])
+ @robot.update_attributes(params[:robot])
+ redirect_to root_path
+ end
+ def destroy
+ @robot = Robot.find(params[:id])
+ @robot.delete
+ redirect_to root_path
end
end
View
@@ -1,2 +1,4 @@
class Robot < ActiveRecord::Base
+ belongs_to :user
+ validates_presence_of :user
end
View
@@ -1,3 +1,4 @@
class User < ActiveRecord::Base
include Clearance::User
+ has_many :robots
end
@@ -0,0 +1,21 @@
+<h1>RobotError</h1>
+<h2 data-role="tagline">a game of robotic shenanigans</h2>
+<% if current_user %>
+ <section data-role="robots">
+ <%= render current_user.robots %>
+ <div>
+ <%= link_to "Create a Robot", new_robot_path %>
+ </div>
+ </section>
+<% else %>
+ <section data-role="welcome-message">
+ <p>Welcome the Error Dome. Please sign up or sign in to get started.</p> </section>
+ <section data-role="sign-up">
+ <h3>Sign up today!</h3>
+ <%= semantic_form_for User.new do |f| %>
+ <%= f.input :email %>
+ <%= f.input :password %>
+ <%= f.action :submit, :as => :button %>
+ <% end %>
+ </section>
+<% end %>
@@ -13,7 +13,16 @@
<%= current_user.email %>
<%= link_to "Sign out", "/sign_out", method: :delete %>
</div>
+ <% else %>
+ <div data-role="user-sign-in">
+ <%= link_to "Sign in", "/sign_in" %>
+ </div>
<% end %>
+ <div data-role="flash">
+ <% flash.each do |key, value| -%>
+ <div class="flash <%= key %>"><%= value %></div>
+ <% end -%>
+ </div>
<%= yield %>
</div>
</body>
@@ -1,16 +0,0 @@
-<h1>RobotError</h1>
-<h2 data-role="tagline">a game of robotic shenanigans</h2>
-<% if logged_in? %>
- <%= link_to "Create a Robot", new_robot_path %>
-<% else %>
-
-<section data-role="welcome-message">
-<p>Welcome the Error Dome. Please sign up or sign in to get started.</p>
-</section>
-<%= form_for User.new do |form| %>
- <%= form.label :email %>
- <%= form.text_field :email %>
- <%= form.label :password %>
- <%= form.password_field :password %>
- <%= form.submit "Sign Up" %>
-<% end %>
@@ -0,0 +1 @@
+<p><%= link_to robot.name, robot_path(robot) %> <%= link_to "edit", edit_robot_path(robot) %> <%= link_to "delete", robot_path(robot), method: 'delete' %></p>
@@ -0,0 +1,4 @@
+<%= semantic_form_for @robot do |form| %>
+ <%= form.input :name %>
+ <%= form.button "ReDeployz!", action: "submit" %>
+<% end %>
No changes.
@@ -32,6 +32,7 @@
# Do not compress assets
config.assets.compress = false
- # Expands the lines which load the assets
config.assets.debug = true
+
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
end
@@ -34,4 +34,7 @@
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
+
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
+ ActiveSupport::Deprecation.silenced = true
end
View
@@ -1,6 +1,6 @@
Roboterror::Application.routes.draw do
- root to: "high_voltage/pages#show", id: "homepage"
+ root to: "homepages#index"
- resources :robots, :only => ['index', 'new', 'create']
+ resources :robots, :only => ['index', 'show', 'new', 'create', 'edit', 'update', 'destroy']
end
@@ -0,0 +1,6 @@
+class AddUsersToRobots < ActiveRecord::Migration
+ def change
+ add_column :robots, :user_id, :integer
+ add_index :robots, :user_id
+ end
+end
View
@@ -11,14 +11,17 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120402004904) do
+ActiveRecord::Schema.define(:version => 20120407235044) do
create_table "robots", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
+ t.integer "user_id"
end
+ add_index "robots", ["user_id"], :name => "index_robots_on_user_id"
+
create_table "users", :force => true do |t|
t.string "email"
t.string "encrypted_password", :limit => 128
@@ -33,4 +36,3 @@
add_index "users", ["remember_token"], :name => "index_users_on_remember_token"
end
-
@@ -1,14 +0,0 @@
-Feature: Accounts are created
- In order to use the application
- As a visitor
- I should be able to create an account, sign in, and sign out
-
- Scenario: Sign up with new email address
- When I sign up as "user@example.com" with the password "tacocat"
- Then I should be signed in as "user@example.com"
-
- Scenario: Sign out
- When I sign up as "user@example.com" with the password "tacocat"
- And I sign out
- Then I should not be signed in
-
@@ -0,0 +1,41 @@
+Feature: Password reset
+
+ In order to sign in even if I forgot my password
+ As a user
+ I want to reset my password
+
+ Scenario: User is not signed up
+ When I reset the password for "unknown.email@example.com"
+ Then I am told email is unknown
+
+ Scenario: User is signed up and requests password reset
+ Given I signed up with "email@example.com"
+ When I reset the password for "email@example.com"
+ Then instructions for changing my password are emailed to "email@example.com"
+
+ Scenario: User tries to reset his password with a blank password
+ Given I signed up with "email@example.com"
+ When I reset the password for "email@example.com"
+ And I follow the password reset link sent to "email@example.com"
+ And I update my password with ""
+ Then I am told to enter a password
+ And I should be signed out
+
+ Scenario: User is signed up and updates his password
+ Given I signed up with "email@example.com"
+ When I reset the password for "email@example.com"
+ And I follow the password reset link sent to "email@example.com"
+ And I update my password with "newpassword"
+ Then I should be signed in
+ When I sign out
+ Then I should be signed out
+ When I sign in with "email@example.com" and "newpassword"
+ Then I should be signed in
+
+ Scenario: User who was created before Clearance was installed creates password for first time
+ Given a user "email@example.com" exists without a salt, remember token, or password
+ When I reset the password for "email@example.com"
+ When I follow the password reset link sent to "email@example.com"
+ And I update my password with "newpassword"
+ Then I should be signed in
+
@@ -0,0 +1,26 @@
+Feature: Sign in
+
+ In order to get access to protected sections of the site
+ As a visitor
+ I want to sign in
+
+ Scenario: Visitor is not signed up
+ When I sign in as "unknown.email@example.com"
+ Then I am told email or password is bad
+ And I should be signed out
+
+ Scenario: Visitor enters wrong password
+ Given I am signed up as "email@example.com"
+ When I sign in as "email@example.com" and "badpassword"
+ Then I am told email or password is bad
+ And I should be signed out
+
+ Scenario: Visitor signs in successfully
+ Given I am signed up as "email@example.com"
+ When I sign in as "email@example.com"
+ Then I should be signed in
+
+ Scenario: Visitor signs in successfully with uppercase email
+ Given I am signed up as "email@example.com"
+ When I sign in as "Email@example.com"
+ Then I should be signed in
@@ -0,0 +1,12 @@
+Feature: Sign out
+
+ In order to protect my account from unauthorized access
+ As a signed in user
+ I want to sign out
+
+ Scenario: User signs out
+ Given I am signed up as "email@example.com"
+ When I sign in as "email@example.com"
+ Then I should be signed in
+ When I sign out
+ Then I should be signed out
@@ -0,0 +1,17 @@
+Feature: Sign up
+
+ In order to access protected sections of the site
+ As a visitor
+ I want to sign up
+
+ Scenario: Visitor signs up with invalid email
+ When I sign up with "invalidemail" and "password"
+ Then I am told to enter a valid email address
+
+ Scenario: Visitor signs up with blank password
+ When I sign up with "email@example.com" and ""
+ Then I am told to enter a password
+
+ Scenario: Visitor signs up with valid data
+ When I sign up with "email@example.com" and "password"
+ Then I should be signed in
@@ -8,4 +8,5 @@ Feature: View public homeage
Then I should see the application name
And I should see the application tagline
And I should see the welcome message
-
+ And I should see the sign in link
+ And I should see the sign up form
@@ -0,0 +1,30 @@
+Feature: As a user
+ In order to manage my robot fleet
+ I should be able to add, edit and delete robots
+
+ Scenario: Create a robot
+ I should be able to create new robots
+ Given I sign in
+ And I create a robot named "Robbie"
+ Then I should see the robot "Robbie" on my homepage
+
+ Scenario: Edit a robot
+ I should be able to edit my robot
+
+ Given I sign in
+ And I create a robot named "Robbie"
+ Then I should be able to edit "Robbie"
+
+ Scenario: Delete a robot
+ I should be able to delete my robot
+
+ Given I sign in
+ And I create a robot named "Robbie"
+ Then I should be able to delete "Robbie"
+
+ Scenario: View a robot
+ I should be able to view my robots
+
+ Given I sign in
+ And I create a robot named "Robbie"
+ Then I should be able to view "Robbie"
@@ -1,10 +0,0 @@
-Feature: Create a new robot
- As a user
- I want to create a new robot
- So that I can begin interacting with the game environment
-
- Scenario: Create a robot
-
- Given I am signed in as "user@exmaple.com"
- Then I should be able to create a robot
- And I should see the robot on my hompage
Oops, something went wrong.

0 comments on commit 48997c7

Please sign in to comment.