Commit 6390f13e77a98361e739f406a420541781a6592c
1 parent
f877c228
Exists in
master
and in
1 other branch
refactor user show view spec
don't use iVars simplify github button specs
Showing
1 changed file
with
7 additions
and
7 deletions
Show diff stats
spec/views/users/show.html.haml_spec.rb
| @@ -2,12 +2,12 @@ require 'spec_helper' | @@ -2,12 +2,12 @@ require 'spec_helper' | ||
| 2 | 2 | ||
| 3 | describe 'users/show.html.haml' do | 3 | describe 'users/show.html.haml' do |
| 4 | let(:user) do | 4 | let(:user) do |
| 5 | - user = stub_model(User, :created_at => Time.now) | 5 | + stub_model(User, :created_at => Time.now) |
| 6 | end | 6 | end |
| 7 | 7 | ||
| 8 | before do | 8 | before do |
| 9 | Errbit::Config.stub(:github_authentication) { true } | 9 | Errbit::Config.stub(:github_authentication) { true } |
| 10 | - controller.stub(:current_user) { Fabricate(:user) } | 10 | + controller.stub(:current_user) { stub_model(User) } |
| 11 | end | 11 | end |
| 12 | 12 | ||
| 13 | context 'with GitHub authentication' do | 13 | context 'with GitHub authentication' do |
| @@ -39,9 +39,8 @@ describe 'users/show.html.haml' do | @@ -39,9 +39,8 @@ describe 'users/show.html.haml' do | ||
| 39 | 39 | ||
| 40 | context 'viewing own user page' do | 40 | context 'viewing own user page' do |
| 41 | before do | 41 | before do |
| 42 | - @user = Fabricate(:user) | ||
| 43 | - controller.stub!(:current_user).and_return(@user) | ||
| 44 | - assign :user, @user | 42 | + controller.stub(:current_user) { user } |
| 43 | + assign :user, user | ||
| 45 | end | 44 | end |
| 46 | 45 | ||
| 47 | it 'shows link github button when no login or token' do | 46 | it 'shows link github button when no login or token' do |
| @@ -50,8 +49,9 @@ describe 'users/show.html.haml' do | @@ -50,8 +49,9 @@ describe 'users/show.html.haml' do | ||
| 50 | end | 49 | end |
| 51 | 50 | ||
| 52 | it 'shows unlink github button when login and token' do | 51 | it 'shows unlink github button when login and token' do |
| 53 | - @user.github_login = 'test_user' | ||
| 54 | - @user.github_oauth_token = 'abcdef' | 52 | + user.github_login = 'test_user' |
| 53 | + user.github_oauth_token = 'abcdef' | ||
| 54 | + | ||
| 55 | render | 55 | render |
| 56 | view.content_for(:action_bar).should include('Unlink GitHub account') | 56 | view.content_for(:action_bar).should include('Unlink GitHub account') |
| 57 | end | 57 | end |