|
39 | 39 | end
|
40 | 40 | end
|
41 | 41 |
|
42 |
| - describe "#create" do |
43 |
| - let(:team) { Fabricate.build(:team, name: 'team_name') } |
| 42 | + describe "#create" , focus: true do |
| 43 | + let(:team) { Fabricate.build(:team) } |
| 44 | + |
| 45 | + it 'renders an error message if action was unsuccessful' do |
44 | 46 |
|
45 |
| - before do |
46 |
| - allow(Team).to receive(:with_similar_names).and_return([]) |
47 | 47 | end
|
48 | 48 |
|
49 | 49 | context 'a team is selected from a list of similar teams' do
|
50 |
| - it 'renders a template with a choice of tariff plans when user picks a name from existing names' do |
51 |
| - allow(Team).to receive(:where).and_return(['team_1', 'team_2']) |
| 50 | + it 'renders a template with a choice of tariff plans when user selects a team' do |
52 | 51 | post :create, :team => { selected: 'true', slug: 'team_name' }, format: :js
|
53 |
| - |
54 |
| - expect(assigns[:team]).to eq('team_1') |
55 |
| - expect(response).to render_template('create') |
56 |
| - end |
57 |
| - |
58 |
| - it 'renders a template with a choice of tariff plans if user picks his own team name' do |
59 |
| - post :create, :team => { name: 'team_name', selected: 'false' }, format: :js |
60 | 52 | expect(response).to render_template('create')
|
61 | 53 | end
|
62 | 54 | end
|
|
65 | 57 | let(:response) { post :create, :team => { name: 'team_name' }, format: :js }
|
66 | 58 |
|
67 | 59 | before do
|
| 60 | + allow(controller).to receive(:get_similar_teams).and_return(nil) |
| 61 | + |
68 | 62 | allow(Team).to receive(:new).and_return(team)
|
69 | 63 | allow(team).to receive(:save).and_return(true)
|
70 | 64 | allow(team).to receive(:add_user).and_return(true)
|
|
88 | 82 | it 'renders template with option to join' do
|
89 | 83 | expect(response).to be_success
|
90 | 84 | expect(response).to render_template('create')
|
91 |
| - expect(flash[:notice]).to eq("Successfully created a team team_name") |
92 |
| - end |
93 |
| - |
94 |
| - it 'renders failure notice' do |
95 |
| - allow(team).to receive(:save).and_return(false) |
96 |
| - response |
97 |
| - expect(flash[:error]).to eq("There was an error in creating a team team_name") |
98 | 85 | end
|
99 | 86 | end
|
100 | 87 |
|
|
106 | 93 |
|
107 | 94 | it 'renders a template with a list of similar teams' do
|
108 | 95 | post :create, :team => { name: 'team_name' }, format: :js
|
109 |
| - |
110 |
| - expect(assigns[:new_team_name]).to eq('team_name') |
111 | 96 | expect(response).to render_template('similar_teams')
|
112 | 97 | end
|
113 | 98 | end
|
|
0 commit comments