From 08a8c60276c0d70949e1e58fd69f33e902e239ff Mon Sep 17 00:00:00 2001 From: Ken Johnson Date: Fri, 31 May 2013 10:48:20 -0400 Subject: [PATCH] added route, controller, model, sidebar link, and basic index page for the work info section so that we can render user data --- app/controllers/work_info_controller.rb | 5 +++++ app/helpers/work_info_helper.rb | 2 ++ app/models/user.rb | 1 + app/models/work_info.rb | 4 ++++ app/views/layouts/shared/_sidebar.html.erb | 4 ++-- app/views/work_info/index.html.erb | 0 config/routes.rb | 3 +++ db/migrate/20130531143853_create_work_infos.rb | 14 ++++++++++++++ test/fixtures/work_infos.yml | 17 +++++++++++++++++ test/functional/work_info_controller_test.rb | 7 +++++++ test/unit/helpers/work_info_helper_test.rb | 4 ++++ test/unit/work_info_test.rb | 7 +++++++ 12 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 app/controllers/work_info_controller.rb create mode 100644 app/helpers/work_info_helper.rb create mode 100644 app/models/work_info.rb create mode 100644 app/views/work_info/index.html.erb create mode 100644 db/migrate/20130531143853_create_work_infos.rb create mode 100644 test/fixtures/work_infos.yml create mode 100644 test/functional/work_info_controller_test.rb create mode 100644 test/unit/helpers/work_info_helper_test.rb create mode 100644 test/unit/work_info_test.rb diff --git a/app/controllers/work_info_controller.rb b/app/controllers/work_info_controller.rb new file mode 100644 index 0000000..a64311a --- /dev/null +++ b/app/controllers/work_info_controller.rb @@ -0,0 +1,5 @@ +class WorkInfoController < ApplicationController + + def index + end +end diff --git a/app/helpers/work_info_helper.rb b/app/helpers/work_info_helper.rb new file mode 100644 index 0000000..627e8e8 --- /dev/null +++ b/app/helpers/work_info_helper.rb @@ -0,0 +1,2 @@ +module WorkInfoHelper +end diff --git a/app/models/user.rb b/app/models/user.rb index ee4c086..f8641f2 100755 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -12,6 +12,7 @@ class User < ActiveRecord::Base before_save :assign_user_id, :on => :create has_one :retirement, :foreign_key => :user_id, :primary_key => :user_id has_one :paid_time_off, :foreign_key => :user_id, :primary_key => :user_id + has_one :work_info, :foreign_key => :user_id, :primary_key => :user_id diff --git a/app/models/work_info.rb b/app/models/work_info.rb new file mode 100644 index 0000000..4eaddcc --- /dev/null +++ b/app/models/work_info.rb @@ -0,0 +1,4 @@ +class WorkInfo < ActiveRecord::Base + attr_accessible :DoB, :SSN, :bonuses, :income, :user_id, :years_worked + belongs_to :user +end diff --git a/app/views/layouts/shared/_sidebar.html.erb b/app/views/layouts/shared/_sidebar.html.erb index 45e8998..a01b719 100755 --- a/app/views/layouts/shared/_sidebar.html.erb +++ b/app/views/layouts/shared/_sidebar.html.erb @@ -43,12 +43,12 @@ <% end %>
  • - + <%= link_to user_work_info_index_path(:user_id => current_user.user_id) do %>
    Work Info -
    + <% end %>
  • diff --git a/app/views/work_info/index.html.erb b/app/views/work_info/index.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/config/routes.rb b/config/routes.rb index 0011cc2..94b3c73 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,9 @@ resources :users do resources :paid_time_off do end + + resources :work_info do + end end diff --git a/db/migrate/20130531143853_create_work_infos.rb b/db/migrate/20130531143853_create_work_infos.rb new file mode 100644 index 0000000..c8ad97b --- /dev/null +++ b/db/migrate/20130531143853_create_work_infos.rb @@ -0,0 +1,14 @@ +class CreateWorkInfos < ActiveRecord::Migration + def change + create_table :work_infos do |t| + t.integer :user_id + t.string :income + t.string :bonuses + t.integer :years_worked + t.string :SSN + t.date :DoB + + t.timestamps + end + end +end diff --git a/test/fixtures/work_infos.yml b/test/fixtures/work_infos.yml new file mode 100644 index 0000000..6aeb3bc --- /dev/null +++ b/test/fixtures/work_infos.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + user_id: 1 + income: MyString + bonuses: MyString + years_worked: 1 + SSN: MyString + DoB: 2013-05-31 + +two: + user_id: 1 + income: MyString + bonuses: MyString + years_worked: 1 + SSN: MyString + DoB: 2013-05-31 diff --git a/test/functional/work_info_controller_test.rb b/test/functional/work_info_controller_test.rb new file mode 100644 index 0000000..56b393a --- /dev/null +++ b/test/functional/work_info_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class WorkInfoControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/helpers/work_info_helper_test.rb b/test/unit/helpers/work_info_helper_test.rb new file mode 100644 index 0000000..f5a236c --- /dev/null +++ b/test/unit/helpers/work_info_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class WorkInfoHelperTest < ActionView::TestCase +end diff --git a/test/unit/work_info_test.rb b/test/unit/work_info_test.rb new file mode 100644 index 0000000..775aec1 --- /dev/null +++ b/test/unit/work_info_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class WorkInfoTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end