|
1 | 1 | require 'spec_helper'
|
2 | 2 |
|
3 |
| -RSpec.describe TeamsController, type: :controller, skip: true do |
| 3 | +RSpec.describe TeamsController, type: :controller do |
4 | 4 | let(:current_user) { Fabricate(:user) }
|
5 | 5 | let(:team) { Fabricate(:team) }
|
6 | 6 |
|
7 | 7 | before { controller.send :sign_in, current_user }
|
8 | 8 |
|
9 | 9 | it 'allows user to follow team' do
|
10 |
| - post :follow, id: team.id |
| 10 | + pending "Fix User#follow_team first" |
| 11 | + post :follow, id: team.id, format: :js |
| 12 | + |
| 13 | + expect(response).to be_success |
| 14 | + current_user.reload |
11 | 15 | expect(current_user.following_team?(team)).to eq(true)
|
12 | 16 | end
|
13 | 17 |
|
14 | 18 | it 'allows user to stop follow team' do
|
| 19 | + pending "Fix User#follow_team first" |
15 | 20 | current_user.follow_team!(team)
|
| 21 | + current_user.reload |
| 22 | + expect(current_user.following_team?(team)).to eq(true) |
16 | 23 | post :follow, id: team.id
|
17 | 24 | current_user.reload
|
18 | 25 | expect(current_user.following_team?(team)).to eq(false)
|
|
27 | 34 | end
|
28 | 35 |
|
29 | 36 | describe 'GET #show' do
|
| 37 | + before do |
| 38 | + url = 'http://maps.googleapis.com/maps/api/geocode/json?address=San%20Francisco,%20CA&language=en&sensor=false' |
| 39 | + @body ||= File.read(File.join(Rails.root, 'spec', 'fixtures', 'google_maps.json')) |
| 40 | + stub_request(:get, url).to_return(body: @body) |
| 41 | + end |
| 42 | + |
30 | 43 | it 'responds successfully with an HTTP 200 status code' do
|
31 | 44 | team = Fabricate(:team) do
|
32 | 45 | name Faker::Company.name
|
|
36 | 49 | expect(response).to be_success
|
37 | 50 | expect(response).to have_http_status(200)
|
38 | 51 | end
|
| 52 | + |
39 | 53 | it 'sets job_page to true if job is found' do
|
40 |
| - opporunity = Fabricate(:opportunity) |
| 54 | + opportunity = Fabricate(:opportunity) |
41 | 55 | get :show, slug: opportunity.team.slug, job_id: opportunity.public_id
|
42 | 56 | expect(assigns(:job_page)).to eq(true)
|
43 | 57 | end
|
| 58 | + |
44 | 59 | it 'sets job_page to false if job is not found' do
|
45 | 60 | team = Fabricate(:team)
|
46 | 61 | get :show, slug: team.slug, job_id: 'not-a-real-job-slug'
|
|
85 | 100 | end
|
86 | 101 |
|
87 | 102 | it 'adds current user to the team' do
|
88 |
| - expect(team).to receive(:add_user).with(current_user) |
| 103 | + expect(team).to receive(:add_user).with(current_user, 'active', 'admin') |
89 | 104 | response
|
90 | 105 | end
|
91 | 106 |
|
|
0 commit comments