diff --git a/.project b/.project new file mode 100644 index 0000000..9bd42ac --- /dev/null +++ b/.project @@ -0,0 +1,18 @@ + + + WhosGotWhat + + + + + + com.aptana.ide.core.unifiedBuilder + + + + + + org.radrails.rails.core.railsnature + com.aptana.ruby.core.rubynature + + diff --git a/app/assets/javascripts/skill_holdings.js b/app/assets/javascripts/skill_holdings.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/skill_holdings.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/skills.js b/app/assets/javascripts/skills.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/skills.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index fdca7c0..c17d45e 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -2,3 +2,36 @@ *= require_self *= require_tree . */ + + table { + font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif; + font-size: 12px; + background: #CCCCCC; + margin: 40px; + width: 480px; + border-collapse: collapse; + text-align: left; + border-top: 4px solid #aabcfe; + border-bottom: 4px solid #aabcfe; + } + th { + font-size: 13px; + font-weight: normal; + padding: 8px; + background: #b9c9fe; + color: #039; + } + td { + padding: 8px; + background: #e8edff; + border-bottom: 1px solid #fff; + color: #669; + border-top: 1px solid #aabcfe; + } + tr:hover td{ + background: #d0dafd; + color: #339; + } + h1 { + margin-left: 20px + } diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss new file mode 100644 index 0000000..05188f0 --- /dev/null +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -0,0 +1,56 @@ +body { + background-color: #fff; + color: #333; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; } + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; } + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; } + +a { + color: #000; + &:visited { + color: #666; } + &:hover { + color: #fff; + background-color: #000; } } + +div { + &.field, &.actions { + margin-bottom: 10px; } } + +#notice { + color: green; } + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; } + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px; + padding-bottom: 0; + margin-bottom: 20px; + background-color: #f0f0f0; + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + margin-bottom: 0px; + background-color: #c00; + color: #fff; } + ul li { + font-size: 12px; + list-style: square; } } diff --git a/app/assets/stylesheets/skill_holdings.css.scss b/app/assets/stylesheets/skill_holdings.css.scss new file mode 100644 index 0000000..b6a3c44 --- /dev/null +++ b/app/assets/stylesheets/skill_holdings.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the skill_holdings controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/skills.css.scss b/app/assets/stylesheets/skills.css.scss new file mode 100644 index 0000000..b6c781d --- /dev/null +++ b/app/assets/stylesheets/skills.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the skills controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/tools.css.scss b/app/assets/stylesheets/tools.css.scss new file mode 100644 index 0000000..1c54797 --- /dev/null +++ b/app/assets/stylesheets/tools.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the tools controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/skill_holdings_controller.rb b/app/controllers/skill_holdings_controller.rb new file mode 100644 index 0000000..6a93b24 --- /dev/null +++ b/app/controllers/skill_holdings_controller.rb @@ -0,0 +1,42 @@ +class SkillHoldingsController < ApplicationController + + def create + @skill_holding = current_user.skill_holdings.build(params[:skill_holding]) + + if @skill_holding.save + redirect_to user_skill_holdings_url(current_user.id) + else + # render :action => "new" + render action: "new" + end + end + + def destroy + @skill_holding = current_user.skill_holdings.find(params[:id]) + @skill_holding.destroy + redirect_to user_skill_holdings_url(current_user.id) + end + + def edit + @skill_holding = current_user.skill_holdings.find(params[:id]) + end + + def index + @skill_holdings = current_user.skill_holdings + end + + def new + @skill_holding = current_user.skill_holdings.build + end + + def update + @skill_holding = current_user.skill_holdings.find(params[:id]) + + if @skill_holding.update_attributes(params[:skill_holding]) + redirect_to user_skill_holdings_url(current_user.id) + else + render action: "edit" + end + end + +end diff --git a/app/controllers/skills_controller.rb b/app/controllers/skills_controller.rb new file mode 100644 index 0000000..e18ca4e --- /dev/null +++ b/app/controllers/skills_controller.rb @@ -0,0 +1,83 @@ +class SkillsController < ApplicationController + # GET /skills + # GET /skills.json + def index + @skills = Skill.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @skills } + end + end + + # GET /skills/1 + # GET /skills/1.json + def show + @skill = Skill.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @skill } + end + end + + # GET /skills/new + # GET /skills/new.json + def new + @skill = Skill.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @skill } + end + end + + # GET /skills/1/edit + def edit + @skill = Skill.find(params[:id]) + end + + # POST /skills + # POST /skills.json + def create + @skill = Skill.new(params[:skill]) + + respond_to do |format| + if @skill.save + format.html { redirect_to @skill, notice: 'Skill was successfully created.' } + format.json { render json: @skill, status: :created, location: @skill } + else + format.html { render action: "new" } + format.json { render json: @skill.errors, status: :unprocessable_entity } + end + end + end + + # PUT /skills/1 + # PUT /skills/1.json + def update + @skill = Skill.find(params[:id]) + + respond_to do |format| + if @skill.update_attributes(params[:skill]) + format.html { redirect_to @skill, notice: 'Skill was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @skill.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /skills/1 + # DELETE /skills/1.json + def destroy + @skill = Skill.find(params[:id]) + @skill.destroy + + respond_to do |format| + format.html { redirect_to skills_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/tools_controller.rb b/app/controllers/tools_controller.rb new file mode 100644 index 0000000..a0a34ad --- /dev/null +++ b/app/controllers/tools_controller.rb @@ -0,0 +1,83 @@ +class ToolsController < ApplicationController + # GET /tools + # GET /tools.json + def index + @tools = Tool.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @tools } + end + end + + # GET /tools/1 + # GET /tools/1.json + def show + @tool = Tool.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @tool } + end + end + + # GET /tools/new + # GET /tools/new.json + def new + @tool = Tool.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @tool } + end + end + + # GET /tools/1/edit + def edit + @tool = Tool.find(params[:id]) + end + + # POST /tools + # POST /tools.json + def create + @tool = Tool.new(params[:tool]) + + respond_to do |format| + if @tool.save + format.html { redirect_to @tool, notice: 'Tool was successfully created.' } + format.json { render json: @tool, status: :created, location: @tool } + else + format.html { render action: "new" } + format.json { render json: @tool.errors, status: :unprocessable_entity } + end + end + end + + # PUT /tools/1 + # PUT /tools/1.json + def update + @tool = Tool.find(params[:id]) + + respond_to do |format| + if @tool.update_attributes(params[:tool]) + format.html { redirect_to @tool, notice: 'Tool was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @tool.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /tools/1 + # DELETE /tools/1.json + def destroy + @tool = Tool.find(params[:id]) + @tool.destroy + + respond_to do |format| + format.html { redirect_to tools_url } + format.json { head :no_content } + end + end +end diff --git a/app/helpers/skill_holdings_helper.rb b/app/helpers/skill_holdings_helper.rb new file mode 100644 index 0000000..e1e8757 --- /dev/null +++ b/app/helpers/skill_holdings_helper.rb @@ -0,0 +1,2 @@ +module SkillHoldingsHelper +end diff --git a/app/helpers/skills_helper.rb b/app/helpers/skills_helper.rb new file mode 100644 index 0000000..5a66444 --- /dev/null +++ b/app/helpers/skills_helper.rb @@ -0,0 +1,2 @@ +module SkillsHelper +end diff --git a/app/helpers/tools_helper.rb b/app/helpers/tools_helper.rb new file mode 100644 index 0000000..6f87959 --- /dev/null +++ b/app/helpers/tools_helper.rb @@ -0,0 +1,2 @@ +module ToolsHelper +end diff --git a/app/models/skill.rb b/app/models/skill.rb new file mode 100644 index 0000000..30cb08a --- /dev/null +++ b/app/models/skill.rb @@ -0,0 +1,8 @@ +class Skill < ActiveRecord::Base + + has_many :skill_holdings + has_many :users, :through => :skill_holdings + + validates :name, :presence => true, :length => {:maximum => 60}, :uniqueness => true + +end diff --git a/app/models/skill_holding.rb b/app/models/skill_holding.rb new file mode 100644 index 0000000..42e1e4b --- /dev/null +++ b/app/models/skill_holding.rb @@ -0,0 +1,28 @@ +class SkillHolding < ActiveRecord::Base + + attr_accessible :level, :name + + belongs_to :user + belongs_to :skill + + validates :level, :numericality => {:minimum => 0, :maximum => 4} + validates :user_id, :presence => true + validates :skill_id, :presence => true + + SKILL_LEVELS = ["Interested in", "Novice", "Intermediate", "Experienced" , "Guru"] + + def level_name + level && SKILL_LEVELS[level] + end + + def name + skill && skill.name + end + + def name=(skill_name) + self.skill = Skill.find_or_create_by_name(skill_name) + save + return name + end + +end diff --git a/app/models/tool.rb b/app/models/tool.rb new file mode 100644 index 0000000..b36babc --- /dev/null +++ b/app/models/tool.rb @@ -0,0 +1,7 @@ +class Tool < ActiveRecord::Base + # attr_accessible :title, :body + attr_accessible :name, :electric, :volts + validates :name, :presence => true + validates :volts, :numericality => {:greater_than => 0}, :if => Proc.new{|tool| tool.electric?} + +end diff --git a/app/models/user.rb b/app/models/user.rb index 18df122..e1324fd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,6 +10,9 @@ class User < ActiveRecord::Base }, :options => { :skip_provider_check => true } + has_many :skill_holdings + has_many :skills, :through => :skill_holdings + has_one :facebook_profile, :dependent => :destroy, :inverse_of => :user validates :first_name, :presence => true diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index f87cae5..3cfb0be 100644 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -1 +1,29 @@ -Welcome <%= current_user.name %> + +<% if current_user == nil %> + Not logged in.
+ <%= link_to "Log in", "/auth/facebook" %> + +<% else %> +

Welcome <%= current_user.name %>

+ + + + + + + + + + +
+ <%= link_to "My skills", user_skill_holdings_path(current_user) %> + + <%= link_to "All skills", skills_path %> + FIXME +
+ My Tools FIXME + + <%= link_to "All Tools", tools_path %> +
+<% end %> + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 27f07d7..22680b5 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,16 +1,69 @@ + + + + + WhosGotWhat <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> + +
+
+
+ Whos Got What +
+
+ <%= render 'shared/flashes' %> + <%= content_for?(:content) ? yield(:content) : yield %> +
+
+ + + -<%= render 'shared/flashes' %> -<%= content_for?(:content) ? yield(:content) : yield %> - diff --git a/app/views/skill_holdings/_form.html.erb b/app/views/skill_holdings/_form.html.erb new file mode 100644 index 0000000..5b73035 --- /dev/null +++ b/app/views/skill_holdings/_form.html.erb @@ -0,0 +1,45 @@ + + +<%= form_for([current_user, @skill_holding]) do |sh| %> + <% if @skill_holding.errors.any? %> +
+

<%= pluralize(@skill_holding.errors.count, "error") %> prohibited this skill holidng from being saved:

+ + +
+ <% end %> + + + + + + + + + + + + + + +
+ <%= sh.label :name, :class => "label_text" %> + + <%= sh.text_field :name %> +
+ <%= sh.label :level, :class => 'label_text' %> + + <%= sh.select :level, SkillHolding::SKILL_LEVELS.collect {|level| [level, SkillHolding::SKILL_LEVELS.find_index(level)] } %> +
+ <%= sh.submit "Add New Skill" %> +
+ +<% end %> diff --git a/app/views/skill_holdings/edit.html.erb b/app/views/skill_holdings/edit.html.erb new file mode 100644 index 0000000..ff2c7b9 --- /dev/null +++ b/app/views/skill_holdings/edit.html.erb @@ -0,0 +1,5 @@ +

Editing skill

+ +<%= render 'form' %> + +<%= link_to 'Back', user_skill_holdings_path(current_user) %> diff --git a/app/views/skill_holdings/index.html.erb b/app/views/skill_holdings/index.html.erb new file mode 100644 index 0000000..bc892ca --- /dev/null +++ b/app/views/skill_holdings/index.html.erb @@ -0,0 +1,27 @@ + +

Listing my skills

+ + + + + + + + +<% @skill_holdings.each do |skill_holding| %> + + + + + +<% end %> + + + +
NameLevelActions
<%= skill_holding.name %><%= skill_holding.level_name %><%= link_to 'Edit', edit_user_skill_holding_path(current_user.id, skill_holding.id) %>, + <%= link_to 'Remove', user_skill_holding_path(current_user.id, skill_holding.id), confirm: 'Are you sure?', method: :delete %>
+ <%= link_to 'New Skill', new_user_skill_holding_path(current_user.id) %> +
+ +
+ diff --git a/app/views/skill_holdings/new.html.erb b/app/views/skill_holdings/new.html.erb new file mode 100644 index 0000000..61c839f --- /dev/null +++ b/app/views/skill_holdings/new.html.erb @@ -0,0 +1,5 @@ +

New Skill

+ +<%= render 'form' %> + +<%= link_to 'Back', user_skill_holdings_path(current_user) %> diff --git a/app/views/skills/_form.html.erb b/app/views/skills/_form.html.erb new file mode 100644 index 0000000..3b231ec --- /dev/null +++ b/app/views/skills/_form.html.erb @@ -0,0 +1,17 @@ +<%= form_for(@skill) do |f| %> + <% if @skill.errors.any? %> +
+

<%= pluralize(@skill.errors.count, "error") %> prohibited this skill from being saved:

+ + +
+ <% end %> + +
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/skills/edit.html.erb b/app/views/skills/edit.html.erb new file mode 100644 index 0000000..60a41d1 --- /dev/null +++ b/app/views/skills/edit.html.erb @@ -0,0 +1,6 @@ +

Editing skill

+ +<%= render 'form' %> + +<%= link_to 'Show', @skill %> | +<%= link_to 'Back', skills_path %> diff --git a/app/views/skills/index.html.erb b/app/views/skills/index.html.erb new file mode 100644 index 0000000..d759faf --- /dev/null +++ b/app/views/skills/index.html.erb @@ -0,0 +1,29 @@ + +

Listing all skills

+ + + + + + + + + +<% @skills.each do |skill| %> + + + + + + +<% end %> + + + + + + +
NameInterestedKnowledgableActions
<%= skill.name%>level 0level 1+<%= link_to 'Show', skill %> + <%= link_to 'Edit', edit_skill_path(skill) %> + <%= link_to 'Destroy', skill, confirm: 'Are you sure?', method: :delete %> +
<%= link_to 'New Skill', new_skill_path %>
diff --git a/app/views/skills/new.html.erb b/app/views/skills/new.html.erb new file mode 100644 index 0000000..a67d54b --- /dev/null +++ b/app/views/skills/new.html.erb @@ -0,0 +1,5 @@ +

New skill

+ +<%= render 'form' %> + +<%= link_to 'Back', skills_path %> diff --git a/app/views/skills/show.html.erb b/app/views/skills/show.html.erb new file mode 100644 index 0000000..9756e29 --- /dev/null +++ b/app/views/skills/show.html.erb @@ -0,0 +1,5 @@ +

<%= notice %>

+ + +<%= link_to 'Edit', edit_skill_path(@skill) %> | +<%= link_to 'Back', skills_path %> diff --git a/app/views/tools/_form.html.erb b/app/views/tools/_form.html.erb new file mode 100644 index 0000000..83ef715 --- /dev/null +++ b/app/views/tools/_form.html.erb @@ -0,0 +1,26 @@ +<%= form_for(@tool) do |f| %> + <% if @tool.errors.any? %> +
+

<%= pluralize(@tool.errors.count, "error") %> prohibited this tool from being saved:

+ + +
+ <% end %> + + <%= f.label :name %>: + <%= f.text_field :name %>
+ + <%= f.label :electric %>: + <%= f.check_box :electric %>
+ + <%= f.label :volts %>: + <%= f.text_field :volts %>
+ +
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/tools/edit.html.erb b/app/views/tools/edit.html.erb new file mode 100644 index 0000000..49cdd83 --- /dev/null +++ b/app/views/tools/edit.html.erb @@ -0,0 +1,6 @@ +

Editing tool

+ +<%= render 'form' %> + +<%= link_to 'Show', @tool %> | +<%= link_to 'Back', tools_path %> diff --git a/app/views/tools/index.html.erb b/app/views/tools/index.html.erb new file mode 100644 index 0000000..d7d836f --- /dev/null +++ b/app/views/tools/index.html.erb @@ -0,0 +1,22 @@ +

Listing tools

+ + + + + + + + +<% @tools.each do |tool| %> + + + + + + +<% end %> +
<%= tool.name %><%= link_to 'Show', tool %><%= link_to 'Edit', edit_tool_path(tool) %><%= link_to 'Destroy', tool, confirm: 'Are you sure?', method: :delete %>
+ +
+ +<%= link_to 'New Tool', new_tool_path %> diff --git a/app/views/tools/new.html.erb b/app/views/tools/new.html.erb new file mode 100644 index 0000000..79a5e74 --- /dev/null +++ b/app/views/tools/new.html.erb @@ -0,0 +1,5 @@ +

New tool

+ +<%= render 'form' %> + +<%= link_to 'Back', tools_path %> diff --git a/app/views/tools/show.html.erb b/app/views/tools/show.html.erb new file mode 100644 index 0000000..501c40e --- /dev/null +++ b/app/views/tools/show.html.erb @@ -0,0 +1,19 @@ +

<%= notice %>

+

Show tool

+ + + Name + <%= @tool.name%> +
+ Electric + <%= @tool.electric%> +
+ <% if @tool.electric %> + Voltage + <%= @tool.volts%> + <% end %> + +
+ +<%= link_to 'Edit', edit_tool_path(@tool) %> | +<%= link_to 'Back', tools_path %> diff --git a/config/application.rb b/config/application.rb index e2bcec3..911e9cf 100644 --- a/config/application.rb +++ b/config/application.rb @@ -48,7 +48,7 @@ class Application < Rails::Application # This will create an empty whitelist of attributes available for mass-assignment for all models # in your app. As such, your models will need to explicitly whitelist or blacklist accessible # parameters by using an attr_accessible or attr_protected declaration. - # config.active_record.whitelist_attributes = true + config.active_record.whitelist_attributes = true # Enable the asset pipeline config.assets.enabled = true diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index ebec1a5..b72aae5 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -4,4 +4,4 @@ # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -WhosGotWhat::Application.config.secret_token = '2a1d27ceb470db8eca79d7f47d1abd4094c287c3caf76a2736dc68af75879899e6662e895f076edfc7daa5048f2e1f0db47847c2b0aed007dd8ca0791c3f8abf' +WhosGotWhat::Application.config.secret_token = 'd8ccc235cfc7b387d0a5b41a7833a8905e01676aae8f38b28b9aea6d43e4d7e2ec8aa06da3622ffa6987e78cbab66c5aebaa7231cdf842cc3663310c047335f1' diff --git a/config/routes.rb b/config/routes.rb index ff0ef76..27563c6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,8 +1,13 @@ WhosGotWhat::Application.routes.draw do + resources :skills + match "/dashboard" => "home#dashboard" - resources :users, :only => [:show] + resources :tools + resources :users, :only => [:show] do + resources :skill_holdings, :except => [:show] + end match "/auth/:provider/callback" => "sessions#create" match "/auth/failure", to: "sessions#failure" diff --git a/db/migrate/20120522025027_create_tools.rb b/db/migrate/20120522025027_create_tools.rb new file mode 100644 index 0000000..df8e437 --- /dev/null +++ b/db/migrate/20120522025027_create_tools.rb @@ -0,0 +1,11 @@ +class CreateTools < ActiveRecord::Migration + def change + create_table :tools do |t| + t.string :name, :null => false, :limit => 60 + t.boolean :electric + t.integer :volts, :default => 120 + + t.timestamps + end + end +end diff --git a/db/migrate/20120605030001_add_owner_to_tools.rb b/db/migrate/20120605030001_add_owner_to_tools.rb new file mode 100644 index 0000000..aea9f70 --- /dev/null +++ b/db/migrate/20120605030001_add_owner_to_tools.rb @@ -0,0 +1,8 @@ +class AddOwnerToTools < ActiveRecord::Migration + def down + remove_column :tools, :owner_id + end + def up + add_column :tools, :owner_id, :integer + end +end diff --git a/db/migrate/20120626022507_create_skills.rb b/db/migrate/20120626022507_create_skills.rb new file mode 100644 index 0000000..fc5d332 --- /dev/null +++ b/db/migrate/20120626022507_create_skills.rb @@ -0,0 +1,18 @@ +class CreateSkills < ActiveRecord::Migration + def change + create_table :skills do |s| + s.string :name, :null => false, :limit => 60 + end + + create_table :skill_holdings do |sh| + sh.integer :user_id, :null => false + sh.integer :skill_id, :null => false + sh.integer :level, :null => false + end + + add_index :skills, :name, :unique => true + add_index :skill_holdings, :user_id + add_index :skill_holdings, :skill_id + + end +end diff --git a/db/schema.rb b/db/schema.rb index 1883d78..3f037fa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120605043307) do +ActiveRecord::Schema.define(:version => 20120626022507) do create_table "facebook_profiles", :force => true do |t| t.string "email", :null => false @@ -59,6 +59,30 @@ add_index "roles_users", ["user_id", "role_id"], :name => "index_roles_users_on_user_id_and_role_id", :unique => true + create_table "skill_holdings", :force => true do |t| + t.integer "user_id", :null => false + t.integer "skill_id", :null => false + t.integer "level", :null => false + end + + add_index "skill_holdings", ["skill_id"], :name => "index_skill_holdings_on_skill_id" + add_index "skill_holdings", ["user_id"], :name => "index_skill_holdings_on_user_id" + + create_table "skills", :force => true do |t| + t.string "name", :limit => 60, :null => false + end + + add_index "skills", ["name"], :name => "index_skills_on_name", :unique => true + + create_table "tools", :force => true do |t| + t.string "name", :limit => 60, :null => false + t.boolean "electric" + t.integer "volts", :default => 120 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "owner_id" + end + create_table "users", :force => true do |t| t.string "first_name", :limit => 60, :null => false t.string "last_name", :limit => 60, :null => false diff --git a/public/WhosGotWhat_728x90.png b/public/WhosGotWhat_728x90.png new file mode 100644 index 0000000..0632530 Binary files /dev/null and b/public/WhosGotWhat_728x90.png differ diff --git a/public/WhosGotWhat_728x90.xcf b/public/WhosGotWhat_728x90.xcf new file mode 100644 index 0000000..e9ad624 Binary files /dev/null and b/public/WhosGotWhat_728x90.xcf differ diff --git a/public/favicon.ico b/public/favicon.ico index e69de29..c5b634f 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/public/favicon.xcf b/public/favicon.xcf new file mode 100644 index 0000000..32a0796 Binary files /dev/null and b/public/favicon.xcf differ diff --git a/spec/controllers/skill_holdings_controller_spec.rb b/spec/controllers/skill_holdings_controller_spec.rb new file mode 100644 index 0000000..22b4bb9 --- /dev/null +++ b/spec/controllers/skill_holdings_controller_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe SkillHoldingsController do + +end diff --git a/spec/controllers/skills_controller_spec.rb b/spec/controllers/skills_controller_spec.rb new file mode 100644 index 0000000..2220fdf --- /dev/null +++ b/spec/controllers/skills_controller_spec.rb @@ -0,0 +1,164 @@ +require 'spec_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. + +describe SkillsController do + + # This should return the minimal set of attributes required to create a valid + # Skill. As you add validations to Skill, be sure to + # update the return value of this method accordingly. + def valid_attributes + {} + end + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # SkillsController. Be sure to keep this updated too. + def valid_session + {} + end + + describe "GET index" do + it "assigns all skills as @skills" do + skill = Skill.create! valid_attributes + get :index, {}, valid_session + assigns(:skills).should eq([skill]) + end + end + + describe "GET show" do + it "assigns the requested skill as @skill" do + skill = Skill.create! valid_attributes + get :show, {:id => skill.to_param}, valid_session + assigns(:skill).should eq(skill) + end + end + + describe "GET new" do + it "assigns a new skill as @skill" do + get :new, {}, valid_session + assigns(:skill).should be_a_new(Skill) + end + end + + describe "GET edit" do + it "assigns the requested skill as @skill" do + skill = Skill.create! valid_attributes + get :edit, {:id => skill.to_param}, valid_session + assigns(:skill).should eq(skill) + end + end + + describe "POST create" do + describe "with valid params" do + it "creates a new Skill" do + expect { + post :create, {:skill => valid_attributes}, valid_session + }.to change(Skill, :count).by(1) + end + + it "assigns a newly created skill as @skill" do + post :create, {:skill => valid_attributes}, valid_session + assigns(:skill).should be_a(Skill) + assigns(:skill).should be_persisted + end + + it "redirects to the created skill" do + post :create, {:skill => valid_attributes}, valid_session + response.should redirect_to(Skill.last) + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved skill as @skill" do + # Trigger the behavior that occurs when invalid params are submitted + Skill.any_instance.stub(:save).and_return(false) + post :create, {:skill => {}}, valid_session + assigns(:skill).should be_a_new(Skill) + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + Skill.any_instance.stub(:save).and_return(false) + post :create, {:skill => {}}, valid_session + response.should render_template("new") + end + end + end + + describe "PUT update" do + describe "with valid params" do + it "updates the requested skill" do + skill = Skill.create! valid_attributes + # Assuming there are no other skills in the database, this + # specifies that the Skill created on the previous line + # receives the :update_attributes message with whatever params are + # submitted in the request. + Skill.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) + put :update, {:id => skill.to_param, :skill => {'these' => 'params'}}, valid_session + end + + it "assigns the requested skill as @skill" do + skill = Skill.create! valid_attributes + put :update, {:id => skill.to_param, :skill => valid_attributes}, valid_session + assigns(:skill).should eq(skill) + end + + it "redirects to the skill" do + skill = Skill.create! valid_attributes + put :update, {:id => skill.to_param, :skill => valid_attributes}, valid_session + response.should redirect_to(skill) + end + end + + describe "with invalid params" do + it "assigns the skill as @skill" do + skill = Skill.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Skill.any_instance.stub(:save).and_return(false) + put :update, {:id => skill.to_param, :skill => {}}, valid_session + assigns(:skill).should eq(skill) + end + + it "re-renders the 'edit' template" do + skill = Skill.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Skill.any_instance.stub(:save).and_return(false) + put :update, {:id => skill.to_param, :skill => {}}, valid_session + response.should render_template("edit") + end + end + end + + describe "DELETE destroy" do + it "destroys the requested skill" do + skill = Skill.create! valid_attributes + expect { + delete :destroy, {:id => skill.to_param}, valid_session + }.to change(Skill, :count).by(-1) + end + + it "redirects to the skills list" do + skill = Skill.create! valid_attributes + delete :destroy, {:id => skill.to_param}, valid_session + response.should redirect_to(skills_url) + end + end + +end diff --git a/spec/helpers/skill_holdings_helper_spec.rb b/spec/helpers/skill_holdings_helper_spec.rb new file mode 100644 index 0000000..d7c1cd7 --- /dev/null +++ b/spec/helpers/skill_holdings_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the SkillHoldingsHelper. For example: +# +# describe SkillHoldingsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe SkillHoldingsHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/skills_helper_spec.rb b/spec/helpers/skills_helper_spec.rb new file mode 100644 index 0000000..f353bf0 --- /dev/null +++ b/spec/helpers/skills_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the SkillsHelper. For example: +# +# describe SkillsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe SkillsHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/skill_spec.rb b/spec/models/skill_spec.rb new file mode 100644 index 0000000..1b1c077 --- /dev/null +++ b/spec/models/skill_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Skill do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/skills_spec.rb b/spec/requests/skills_spec.rb new file mode 100644 index 0000000..c1f8f14 --- /dev/null +++ b/spec/requests/skills_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe "Skills" do + describe "GET /skills" do + it "works! (now write some real specs)" do + # Run the generator again with the --webrat flag if you want to use webrat methods/matchers + get skills_path + response.status.should be(200) + end + end +end diff --git a/spec/routing/skills_routing_spec.rb b/spec/routing/skills_routing_spec.rb new file mode 100644 index 0000000..d2e6e2e --- /dev/null +++ b/spec/routing/skills_routing_spec.rb @@ -0,0 +1,35 @@ +require "spec_helper" + +describe SkillsController do + describe "routing" do + + it "routes to #index" do + get("/skills").should route_to("skills#index") + end + + it "routes to #new" do + get("/skills/new").should route_to("skills#new") + end + + it "routes to #show" do + get("/skills/1").should route_to("skills#show", :id => "1") + end + + it "routes to #edit" do + get("/skills/1/edit").should route_to("skills#edit", :id => "1") + end + + it "routes to #create" do + post("/skills").should route_to("skills#create") + end + + it "routes to #update" do + put("/skills/1").should route_to("skills#update", :id => "1") + end + + it "routes to #destroy" do + delete("/skills/1").should route_to("skills#destroy", :id => "1") + end + + end +end diff --git a/spec/views/skills/edit.html.erb_spec.rb b/spec/views/skills/edit.html.erb_spec.rb new file mode 100644 index 0000000..b1330b3 --- /dev/null +++ b/spec/views/skills/edit.html.erb_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "skills/edit" do + before(:each) do + @skill = assign(:skill, stub_model(Skill)) + end + + it "renders the edit skill form" do + render + + # Run the generator again with the --webrat flag if you want to use webrat matchers + assert_select "form", :action => skills_path(@skill), :method => "post" do + end + end +end diff --git a/spec/views/skills/index.html.erb_spec.rb b/spec/views/skills/index.html.erb_spec.rb new file mode 100644 index 0000000..cae82bc --- /dev/null +++ b/spec/views/skills/index.html.erb_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "skills/index" do + before(:each) do + assign(:skills, [ + stub_model(Skill), + stub_model(Skill) + ]) + end + + it "renders a list of skills" do + render + # Run the generator again with the --webrat flag if you want to use webrat matchers + end +end diff --git a/spec/views/skills/new.html.erb_spec.rb b/spec/views/skills/new.html.erb_spec.rb new file mode 100644 index 0000000..1f3ace4 --- /dev/null +++ b/spec/views/skills/new.html.erb_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "skills/new" do + before(:each) do + assign(:skill, stub_model(Skill).as_new_record) + end + + it "renders new skill form" do + render + + # Run the generator again with the --webrat flag if you want to use webrat matchers + assert_select "form", :action => skills_path, :method => "post" do + end + end +end diff --git a/spec/views/skills/show.html.erb_spec.rb b/spec/views/skills/show.html.erb_spec.rb new file mode 100644 index 0000000..e8c1e28 --- /dev/null +++ b/spec/views/skills/show.html.erb_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe "skills/show" do + before(:each) do + @skill = assign(:skill, stub_model(Skill)) + end + + it "renders attributes in

" do + render + # Run the generator again with the --webrat flag if you want to use webrat matchers + end +end diff --git a/test/fixtures/tools.yml b/test/fixtures/tools.yml new file mode 100644 index 0000000..c63aac0 --- /dev/null +++ b/test/fixtures/tools.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/functional/tools_controller_test.rb b/test/functional/tools_controller_test.rb new file mode 100644 index 0000000..5175c21 --- /dev/null +++ b/test/functional/tools_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class ToolsControllerTest < ActionController::TestCase + setup do + @tool = tools(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:tools) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create tool" do + assert_difference('Tool.count') do + post :create, tool: { } + end + + assert_redirected_to tool_path(assigns(:tool)) + end + + test "should show tool" do + get :show, id: @tool + assert_response :success + end + + test "should get edit" do + get :edit, id: @tool + assert_response :success + end + + test "should update tool" do + put :update, id: @tool, tool: { } + assert_redirected_to tool_path(assigns(:tool)) + end + + test "should destroy tool" do + assert_difference('Tool.count', -1) do + delete :destroy, id: @tool + end + + assert_redirected_to tools_path + end +end diff --git a/test/unit/helpers/tools_helper_test.rb b/test/unit/helpers/tools_helper_test.rb new file mode 100644 index 0000000..0677abe --- /dev/null +++ b/test/unit/helpers/tools_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class ToolsHelperTest < ActionView::TestCase +end diff --git a/test/unit/tool_test.rb b/test/unit/tool_test.rb new file mode 100644 index 0000000..4d28156 --- /dev/null +++ b/test/unit/tool_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ToolTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end