This file contains hidden or 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
| (def x-type (ref "")) | |
| (def o-type (ref "")) | |
| (defn update-player-type [piece new-type] | |
| (if (= piece "X") | |
| (dosync (ref-set x-type new-type)) | |
| (dosync (ref-set o-type new-type)))) | |
| (update-player-type "X" "human") | |
| (update-player-type "O" "computer") |
This file contains hidden or 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
| class Applicant | |
| attr_accessor :name, :applied_on | |
| def initialize(name, applied_on) | |
| @name = name | |
| @applied_on = applied_on | |
| end | |
| def <=>(other) | |
| applied_on <=> other.applied_on | |
| end |
This file contains hidden or 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
| it "raises RecordNotFound error" do | |
| expect { repo.find(1) }.to raise_exception(Footprints::RecordNotFound) | |
| end |
This file contains hidden or 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
| describe ArRepository::ApplicantRepository do | |
| it_behaves_like "applicant repository" | |
| end |
This file contains hidden or 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
| shared_examples "applicant repository" do | |
| let(:yesterday) { Date.yesterday } | |
| let(:today) { Date.today } | |
| let(:repo) { described_class.new } | |
| let(:attrs) {{ | |
| :name => "test applicant", | |
| :email => "test@example.com", | |
| :applied_on => today | |
| }} |
This file contains hidden or 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
| describe Applicant do | |
| let(:today) { Date.today } | |
| let(:yesterday) { Date.yesterday } | |
| let(:tomorrow) { Date.tomorrow } | |
| let(:attrs) {{ | |
| :name => "Meagan Waller", | |
| :email => "meagan@test.com", | |
| :applied_on => yesterday }} | |
| context "validation" do |
This file contains hidden or 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
| describe HomeController do | |
| describe "GET index" do | |
| it "successfully displays the page" do | |
| ApplicationController.any_instance.stub(:logged_in?).and_return(true) | |
| get :index | |
| (expect(response.status).to eq(200)) | |
| end | |
| it "redirects to login page when not logged in" do | |
| get :index |
This file contains hidden or 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
| describe "GET index" do | |
| it "displays craftsmen with appentices" do | |
| craftsman = repo.craftsman.create(name: "Name", status: "Has Apprentice") | |
| get :index | |
| expect(assigns(:with_apprentice)).to eq([craftsman]) | |
| end | |
| it "displays other craftsmen" do | |
| craftsman1 = repo.craftsman.create(name: "A Name", status: "Not Interested") | |
| craftsman2 = repo.craftsman.create(name: "B Name", status: "Too Busy") |
This file contains hidden or 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
| class ApplicantsController < ApplicationController | |
| before_filter :authenticate | |
| before_filter :modify_date_params, :only => [:create, :update] | |
| include ApplicantsHelper | |
| def create | |
| @applicant = repo.applicant.new(applicant_params) | |
| if @applicant.save | |
| redirect_to(applicant_path(@applicant), :notice => "Successfully created #{@applicant.name}.") |
This file contains hidden or 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
| class ApplicantsController < ApplicationController | |
| private | |
| def applicant_params | |
| params.require(:applicant).permit(:name, :email, :applied_on, :initial_reply_on, :completed_ttt_on, :reviewed_on, :resubmitted_ttt_on, :decision_made_on, :assigned_craftsman, :ttt_repo_link, :codeschool, :college_degree, :cs_degree, :worked_as_dev, :additional_notes) | |
| end | |
| end |