Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix: Rename bids to sells and price to number_of_shares.

  • Loading branch information...
commit 09ca8d27f8fc5dd2640fa572d450edd944284263 1 parent d330a21
@jackquack authored
Showing with 153 additions and 133 deletions.
  1. +1 −1  app/assets/stylesheets/bids.css.scss
  2. +0 −7 app/controllers/bids_controller.rb
  3. +7 −0 app/controllers/sells_controller.rb
  4. +0 −2  app/helpers/bids_helper.rb
  5. +2 −0  app/helpers/sells_helper.rb
  6. +0 −5 app/models/bid.rb
  7. +1 −1  app/models/buy.rb
  8. +1 −1  app/models/prediction.rb
  9. +5 −0 app/models/sell.rb
  10. +1 −1  app/models/user.rb
  11. +0 −14 app/views/bids/_form.html.haml
  12. +0 −7 app/views/bids/edit.html.haml
  13. +0 −21 app/views/bids/index.html.haml
  14. +0 −5 app/views/bids/new.html.haml
  15. +0 −12 app/views/bids/show.html.haml
  16. +2 −2 app/views/buys/_form.html.haml
  17. +2 −2 app/views/buys/index.html.haml
  18. +2 −2 app/views/buys/show.html.haml
  19. +11 −11 app/views/predictions/show.html.haml
  20. +14 −0 app/views/sells/_form.html.haml
  21. +7 −0 app/views/sells/edit.html.haml
  22. +21 −0 app/views/sells/index.html.haml
  23. +5 −0 app/views/sells/new.html.haml
  24. +12 −0 app/views/sells/show.html.haml
  25. +2 −2 config/routes.rb
  26. +9 −0 db/migrate/20130323171725_rename_bids_to_sell.rb
  27. +11 −0 db/migrate/20130323172552_rename_price_to_number_of_shares.rb
  28. +12 −12 db/schema.rb
  29. +2 −2 test/fixtures/bids.yml
  30. +2 −2 test/fixtures/buys.yml
  31. +17 −17 test/functional/bids_controller_test.rb
  32. +2 −2 test/functional/buys_controller_test.rb
  33. +1 −1  test/unit/bid_test.rb
  34. +1 −1  test/unit/helpers/bids_helper_test.rb
View
2  app/assets/stylesheets/bids.css.scss
@@ -1,3 +1,3 @@
-// Place all the styles related to the Bids controller here.
+// Place all the styles related to the Sells controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
View
7 app/controllers/bids_controller.rb
@@ -1,7 +0,0 @@
-class BidsController < InheritedResources::Base
- belongs_to :prediction, :optional => true
- def create
- params[:bid][:user_id] = current_user.id
- create!
- end
-end
View
7 app/controllers/sells_controller.rb
@@ -0,0 +1,7 @@
+class SellsController < InheritedResources::Base
+ belongs_to :prediction, :optional => true
+ def create
+ params[:sell][:user_id] = current_user.id
+ create!
+ end
+end
View
2  app/helpers/bids_helper.rb
@@ -1,2 +0,0 @@
-module BidsHelper
-end
View
2  app/helpers/sells_helper.rb
@@ -0,0 +1,2 @@
+module SellsHelper
+end
View
5 app/models/bid.rb
@@ -1,5 +0,0 @@
-class Bid < ActiveRecord::Base
- attr_accessible :price, :user_id, :prediction_id
- belongs_to :prediction
- belongs_to :user
-end
View
2  app/models/buy.rb
@@ -1,5 +1,5 @@
class Buy < ActiveRecord::Base
- attr_accessible :prediction_id, :price, :user_id
+ attr_accessible :prediction_id, :number_of_shares, :user_id
belongs_to :prediction
belongs_to :user
end
View
2  app/models/prediction.rb
@@ -1,6 +1,6 @@
class Prediction < ActiveRecord::Base
attr_accessible :end_date, :name, :prediction, :source, :verified_by
- has_many :bids
+ has_many :sells
has_many :buys
belongs_to :user
end
View
5 app/models/sell.rb
@@ -0,0 +1,5 @@
+class Sell < ActiveRecord::Base
+ attr_accessible :number_of_shares, :user_id, :prediction_id
+ belongs_to :prediction
+ belongs_to :user
+end
View
2  app/models/user.rb
@@ -3,7 +3,7 @@ class User < ActiveRecord::Base
devise :omniauthable, :omniauth_providers => [:facebook]
has_many :predictions
- has_many :bids
+ has_many :sells
has_many :buys
# Setup accessible (or protected) attributes for your model
View
14 app/views/bids/_form.html.haml
@@ -1,14 +0,0 @@
-= form_for @bid do |f|
- - if @bid.errors.any?
- #error_explanation
- %h2= "#{pluralize(@bid.errors.count, "error")} prohibited this bid from being saved:"
- %ul
- - @bid.errors.full_messages.each do |msg|
- %li= msg
-
- .field
- = f.label :price
- = f.text_field :price
- = f.hidden_field :prediction_id, :value => @prediction.id
- .actions
- = f.submit 'Save'
View
7 app/views/bids/edit.html.haml
@@ -1,7 +0,0 @@
-%h1 Editing bid
-
-= render 'form'
-
-= link_to 'Show', @bid
-\|
-= link_to 'Back', bids_path
View
21 app/views/bids/index.html.haml
@@ -1,21 +0,0 @@
-%h1 Listing bids
-
-%table
- %tr
- %th Price
- %th User
- %th
- %th
- %th
-
- - @bids.each do |bid|
- %tr
- %td= bid.price
- %td= bid.user_id
- %td= link_to 'Show', bid
- %td= link_to 'Edit', edit_bid_path(bid)
- %td= link_to 'Destroy', bid, :method => :delete, :data => { :confirm => 'Are you sure?' }
-
-%br
-
-= link_to 'New Bid', new_bid_path
View
5 app/views/bids/new.html.haml
@@ -1,5 +0,0 @@
-%h1 New bid
-
-= render 'form'
-
-= link_to 'Back', bids_path
View
12 app/views/bids/show.html.haml
@@ -1,12 +0,0 @@
-%p#notice= notice
-
-%p
- %b Price:
- = @bid.price
-%p
- %b User:
- = @bid.user_id
-
-= link_to 'Edit', edit_bid_path(@bid)
-\|
-= link_to 'Back', prediction_path(@bid.prediction_id)
View
4 app/views/buys/_form.html.haml
@@ -7,8 +7,8 @@
%li= msg
.field
- = f.label :price
- = f.text_field :price
+ = f.label :number_of_shares
+ = f.text_field :number_of_shares
= f.hidden_field :prediction_id, :value => @prediction.id
.actions
= f.submit 'Save'
View
4 app/views/buys/index.html.haml
@@ -2,7 +2,7 @@
%table
%tr
- %th Price
+ %th NumberOfShares
%th User
%th Prediction
%th
@@ -11,7 +11,7 @@
- @buys.each do |buy|
%tr
- %td= buy.price
+ %td= buy.number_of_shares
%td= buy.user_id
%td= buy.prediction_id
%td= link_to 'Show', buy
View
4 app/views/buys/show.html.haml
@@ -1,8 +1,8 @@
%p#notice= notice
%p
- %b Price:
- = @buy.price
+ %b NumberOfShares:
+ = @buy.number_of_shares
%p
%b User:
= @buy.user_id
View
22 app/views/predictions/show.html.haml
@@ -11,32 +11,32 @@
= @prediction.user.name
%h1 Place Your Bits
-%h2 Listing bids
+%h2 Listing sells
%table
%tr
- %th Price
+ %th NumberOfShares
%th User
%th
%th
%th
- - @prediction.bids.each do |bid|
+ - @prediction.sells.each do |sell|
%tr
- %td= bid.price
- %td= bid.user.name
- %td= link_to 'Show', bid
- %td= link_to 'Edit', edit_bid_path(bid)
- %td= link_to 'Destroy', bid, :method => :delete, :data => { :confirm => 'Are you sure?' }
+ %td= sell.number_of_shares
+ %td= sell.user.name
+ %td= link_to 'Show', sell
+ %td= link_to 'Edit', edit_sell_path(sell)
+ %td= link_to 'Destroy', sell, :method => :delete, :data => { :confirm => 'Are you sure?' }
%br
-= link_to 'New Bid', new_prediction_bid_path(@prediction.id)
+= link_to 'New Sell', new_prediction_sell_path(@prediction.id)
%h2 Listing buys
%table
%tr
- %th Price
+ %th NumberOfShares
%th User
%th Prediction
%th
@@ -45,7 +45,7 @@
- @prediction.buys.each do |buy|
%tr
- %td= buy.price
+ %td= buy.number_of_shares
%td= buy.user.name
%td= buy.prediction_id
%td= link_to 'Show', buy
View
14 app/views/sells/_form.html.haml
@@ -0,0 +1,14 @@
+= form_for @sell do |f|
+ - if @sell.errors.any?
+ #error_explanation
+ %h2= "#{pluralize(@sell.errors.count, "error")} prohibited this sell from being saved:"
+ %ul
+ - @sell.errors.full_messages.each do |msg|
+ %li= msg
+
+ .field
+ = f.label :number_of_shares
+ = f.text_field :number_of_shares
+ = f.hidden_field :prediction_id, :value => @prediction.id
+ .actions
+ = f.submit 'Save'
View
7 app/views/sells/edit.html.haml
@@ -0,0 +1,7 @@
+%h1 Editing sell
+
+= render 'form'
+
+= link_to 'Show', @sell
+\|
+= link_to 'Back', sells_path
View
21 app/views/sells/index.html.haml
@@ -0,0 +1,21 @@
+%h1 Listing sells
+
+%table
+ %tr
+ %th NumberOfShares
+ %th User
+ %th
+ %th
+ %th
+
+ - @sells.each do |sell|
+ %tr
+ %td= sell.number_of_shares
+ %td= sell.user_id
+ %td= link_to 'Show', sell
+ %td= link_to 'Edit', edit_sell_path(sell)
+ %td= link_to 'Destroy', sell, :method => :delete, :data => { :confirm => 'Are you sure?' }
+
+%br
+
+= link_to 'New Sell', new_sell_path
View
5 app/views/sells/new.html.haml
@@ -0,0 +1,5 @@
+%h1 New sell
+
+= render 'form'
+
+= link_to 'Back', sells_path
View
12 app/views/sells/show.html.haml
@@ -0,0 +1,12 @@
+%p#notice= notice
+
+%p
+ %b NumberOfShares:
+ = @sell.number_of_shares
+%p
+ %b User:
+ = @sell.user_id
+
+= link_to 'Edit', edit_sell_path(@sell)
+\|
+= link_to 'Back', prediction_path(@sell.prediction_id)
View
4 config/routes.rb
@@ -1,9 +1,9 @@
BitPredictor::Application.routes.draw do
resources :buys
- resources :bids
+ resources :sells
resources :predictions do
resources :buys
- resources :bids
+ resources :sells
end
devise_for :users, :controllers => { :omniauth_callbacks => "omniauth_callbacks"}
View
9 db/migrate/20130323171725_rename_bids_to_sell.rb
@@ -0,0 +1,9 @@
+class RenameBidsToSell < ActiveRecord::Migration
+ def self.up
+ rename_table :bids, :sells
+ end
+
+ def self.down
+ rename_table :sells, :bids
+ end
+end
View
11 db/migrate/20130323172552_rename_price_to_number_of_shares.rb
@@ -0,0 +1,11 @@
+class RenamePriceToNumberOfShares < ActiveRecord::Migration
+ def up
+ rename_column :sells, :price, :number_of_shares
+ rename_column :buys, :price, :number_of_shares
+ end
+
+ def down
+ rename_column :sells, :price, :number_of_shares
+ rename_column :buys, :price, :number_of_shares
+ end
+end
View
24 db/schema.rb
@@ -11,22 +11,14 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130323155754) do
-
- create_table "bids", :force => true do |t|
- t.decimal "price", :precision => 10, :scale => 0
- t.integer "user_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.integer "prediction_id"
- end
+ActiveRecord::Schema.define(:version => 20130323172552) do
create_table "buys", :force => true do |t|
- t.decimal "price", :precision => 10, :scale => 0
+ t.decimal "number_of_shares", :precision => 10, :scale => 0
t.integer "user_id"
t.integer "prediction_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
create_table "predictions", :force => true do |t|
@@ -40,6 +32,14 @@
t.integer "user_id"
end
+ create_table "sells", :force => true do |t|
+ t.decimal "number_of_shares", :precision => 10, :scale => 0
+ t.integer "user_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.integer "prediction_id"
+ end
+
create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
View
4 test/fixtures/bids.yml
@@ -1,9 +1,9 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
- price: 9.99
+ number_of_shares: 9.99
user_id: 1
two:
- price: 9.99
+ number_of_shares: 9.99
user_id: 1
View
4 test/fixtures/buys.yml
@@ -1,11 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
- price: 9.99
+ number_of_shares: 9.99
user_id: 1
prediction_id: 1
two:
- price: 9.99
+ number_of_shares: 9.99
user_id: 1
prediction_id: 1
View
34 test/functional/bids_controller_test.rb
@@ -1,14 +1,14 @@
require 'test_helper'
-class BidsControllerTest < ActionController::TestCase
+class SellsControllerTest < ActionController::TestCase
setup do
- @bid = bids(:one)
+ @sell = sells(:one)
end
test "should get index" do
get :index
assert_response :success
- assert_not_nil assigns(:bids)
+ assert_not_nil assigns(:sells)
end
test "should get new" do
@@ -16,34 +16,34 @@ class BidsControllerTest < ActionController::TestCase
assert_response :success
end
- test "should create bid" do
- assert_difference('Bid.count') do
- post :create, bid: { price: @bid.price, user_id: @bid.user_id }
+ test "should create sell" do
+ assert_difference('Sell.count') do
+ post :create, sell: { number_of_shares: @sell.number_of_shares, user_id: @sell.user_id }
end
- assert_redirected_to bid_path(assigns(:bid))
+ assert_redirected_to sell_path(assigns(:sell))
end
- test "should show bid" do
- get :show, id: @bid
+ test "should show sell" do
+ get :show, id: @sell
assert_response :success
end
test "should get edit" do
- get :edit, id: @bid
+ get :edit, id: @sell
assert_response :success
end
- test "should update bid" do
- put :update, id: @bid, bid: { price: @bid.price, user_id: @bid.user_id }
- assert_redirected_to bid_path(assigns(:bid))
+ test "should update sell" do
+ put :update, id: @sell, sell: { number_of_shares: @sell.number_of_shares, user_id: @sell.user_id }
+ assert_redirected_to sell_path(assigns(:sell))
end
- test "should destroy bid" do
- assert_difference('Bid.count', -1) do
- delete :destroy, id: @bid
+ test "should destroy sell" do
+ assert_difference('Sell.count', -1) do
+ delete :destroy, id: @sell
end
- assert_redirected_to bids_path
+ assert_redirected_to sells_path
end
end
View
4 test/functional/buys_controller_test.rb
@@ -18,7 +18,7 @@ class BuysControllerTest < ActionController::TestCase
test "should create buy" do
assert_difference('Buy.count') do
- post :create, buy: { prediction_id: @buy.prediction_id, price: @buy.price, user_id: @buy.user_id }
+ post :create, buy: { prediction_id: @buy.prediction_id, number_of_shares: @buy.number_of_shares, user_id: @buy.user_id }
end
assert_redirected_to buy_path(assigns(:buy))
@@ -35,7 +35,7 @@ class BuysControllerTest < ActionController::TestCase
end
test "should update buy" do
- put :update, id: @buy, buy: { prediction_id: @buy.prediction_id, price: @buy.price, user_id: @buy.user_id }
+ put :update, id: @buy, buy: { prediction_id: @buy.prediction_id, number_of_shares: @buy.number_of_shares, user_id: @buy.user_id }
assert_redirected_to buy_path(assigns(:buy))
end
View
2  test/unit/bid_test.rb
@@ -1,6 +1,6 @@
require 'test_helper'
-class BidTest < ActiveSupport::TestCase
+class SellTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
View
2  test/unit/helpers/bids_helper_test.rb
@@ -1,4 +1,4 @@
require 'test_helper'
-class BidsHelperTest < ActionView::TestCase
+class SellsHelperTest < ActionView::TestCase
end
Please sign in to comment.
Something went wrong with that request. Please try again.