Skip to content

Commit a7fa4eb

Browse files
authored
Merge pull request #5 from DBC-BootUp/rspec
Rspec for company model associations
2 parents b868c8b + d3df52a commit a7fa4eb

13 files changed

+99
-36
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ group :development, :test do
4040
gem "factory_bot_rails", "~> 4.0"
4141
gem 'faker', :git => 'https://github.com/stympy/faker.git', :branch => 'master'
4242
gem 'dotenv-rails'
43+
gem 'shoulda-matchers', '~> 3.1'
4344
end
4445

4546
group :development do

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ GEM
154154
sprockets (>= 2.8, < 4.0)
155155
sprockets-rails (>= 2.0, < 4.0)
156156
tilt (>= 1.1, < 3)
157+
shoulda-matchers (3.1.2)
158+
activesupport (>= 4.0.0)
157159
spring (2.0.2)
158160
activesupport (>= 4.2)
159161
spring-watcher-listen (2.0.1)
@@ -198,6 +200,7 @@ DEPENDENCIES
198200
rails-controller-testing
199201
rspec-rails
200202
sass-rails (~> 5.0)
203+
shoulda-matchers (~> 3.1)
201204
spring
202205
spring-watcher-listen (~> 2.0.0)
203206
tzinfo-data

app/controllers/companies_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ def destroy
3535

3636
private
3737
def company_params
38-
params.require(:company).permit(:name, :location, :website, :tech_field, :has_apprenticeship?)
38+
params.require(:company).permit(:name, :location, :website, :tech_field, :has_apprenticeship)
3939
end
4040
end

app/controllers/interviews_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ def destroy
3939

4040
private
4141
def interview_params
42-
params.require(:interview).permit(:job_title, :referred?, :received_offer?, :notes, :difficulty_rating, :experience_rating, :accepted_offer?, :phone_screen?, :phone_screen_details, :tech_screen?, :tech_screen_details, :take_home_challenge?, :take_home_challenge_details, :onsite?, :onsite_details, :whiteboarding?, :whiteboarding_details, :negotiation_details, :user_id, :company_id)
42+
params.require(:interview).permit(:job_title, :referred, :received_offer, :notes, :difficulty_rating, :experience_rating, :accepted_offer, :phone_screen, :phone_screen_details, :tech_screen, :tech_screen_details, :take_home_challenge, :take_home_challenge_details, :onsite, :onsite_details, :whiteboarding, :whiteboarding_details, :negotiation_details, :user_id, :company_id)
4343
end
4444
end

db/migrate/20171204010457_create_companies.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def change
55
t.string :location
66
t.string :website
77
t.string :tech_field
8-
t.boolean :has_apprenticeship?
8+
t.boolean :has_apprenticeship
99

1010
t.timestamps
1111
end

db/migrate/20171204013338_create_interviews.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ class CreateInterviews < ActiveRecord::Migration[5.1]
22
def change
33
create_table :interviews do |t|
44
t.string :job_title
5-
t.boolean :referred?
6-
t.boolean :received_offer?
5+
t.boolean :referred
6+
t.boolean :received_offer
77
t.text :notes
88
t.integer :difficulty_rating
99
t.integer :experience_rating
10-
t.boolean :accepted_offer?
11-
t.boolean :phone_screen?
10+
t.boolean :accepted_offer
11+
t.boolean :phone_screen
1212
t.text :phone_screen_details
13-
t.boolean :tech_screen?
13+
t.boolean :tech_screen
1414
t.text :tech_screen_details
15-
t.boolean :take_home_challenge?
15+
t.boolean :take_home_challenge
1616
t.text :take_home_challenge_details
17-
t.boolean :onsite?
17+
t.boolean :onsite
1818
t.text :onsite_details
19-
t.boolean :whiteboarding?
19+
t.boolean :whiteboarding
2020
t.text :whiteboarding_details
2121
t.text :negotiation_details
2222
t.references :user

db/schema.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
t.string "location"
2121
t.string "website"
2222
t.string "tech_field"
23-
t.boolean "has_apprenticeship?"
23+
t.boolean "has_apprenticeship"
2424
t.datetime "created_at", null: false
2525
t.datetime "updated_at", null: false
2626
end
@@ -34,21 +34,21 @@
3434

3535
create_table "interviews", force: :cascade do |t|
3636
t.string "job_title"
37-
t.boolean "referred?"
38-
t.boolean "received_offer?"
37+
t.boolean "referred"
38+
t.boolean "received_offer"
3939
t.text "notes"
4040
t.integer "difficulty_rating"
4141
t.integer "experience_rating"
42-
t.boolean "accepted_offer?"
43-
t.boolean "phone_screen?"
42+
t.boolean "accepted_offer"
43+
t.boolean "phone_screen"
4444
t.text "phone_screen_details"
45-
t.boolean "tech_screen?"
45+
t.boolean "tech_screen"
4646
t.text "tech_screen_details"
47-
t.boolean "take_home_challenge?"
47+
t.boolean "take_home_challenge"
4848
t.text "take_home_challenge_details"
49-
t.boolean "onsite?"
49+
t.boolean "onsite"
5050
t.text "onsite_details"
51-
t.boolean "whiteboarding?"
51+
t.boolean "whiteboarding"
5252
t.text "whiteboarding_details"
5353
t.text "negotiation_details"
5454
t.bigint "user_id"

package-lock.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/controllers/companies_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
end
1010
end
1111

12-
describe "GET #create" do
12+
describe "POST #create" do
1313
it "returns http success" do
14-
get :create
14+
post :create, params: {company: {name: 'Create', location: 'placeName', website: 'cnn.com', tech_field: 'edtech', has_apprenticeship: true}}
1515
expect(response).to have_http_status(:success)
1616
end
1717
end

spec/factories/companies.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
location { "#{Faker::Address.city}, #{Faker::Address.state}" }
77
website { Faker::Internet.url }
88
tech_field { Faker::Company.catch_phrase }
9-
has_apprenticeship? { [true, false].sample }
10-
skills do
9+
has_apprenticeship { [true, false].sample }
10+
skills do
1111
FactoryBot.create(:skill) until Skill.all.length > skill_count
1212
Skill.all.sample(skill_count)
1313
end

0 commit comments

Comments
 (0)