This repository has been archived by the owner on Nov 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add testcase for user signin context
- Loading branch information
Showing
10 changed files
with
142 additions
and
107 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
class DashboardController < ApplicationController | ||
def index | ||
@revisions = Revision.order(date: :desc).limit(4) | ||
def index | ||
p current_user | ||
@revisions = Revision.order(date: :desc).limit(4) | ||
end | ||
end |
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,40 @@ | ||
require 'spec_helper' | ||
|
||
describe DashboardController do | ||
|
||
before do | ||
user = User.create! | ||
user.save | ||
sign_in user | ||
context "not sign-in" do | ||
describe "GET 'index'" do | ||
before { get 'index' } | ||
subject { response } | ||
it { should redirect_to(new_user_session_path) } | ||
end | ||
end | ||
|
||
describe "GET 'index'" do | ||
context "user sign-in" do | ||
before do | ||
@foo = create(:revision, hash_code: 'foo') | ||
@bar = create(:revision, hash_code: 'bar') | ||
@baz = create(:revision, hash_code: 'baz') | ||
get 'index' | ||
user = User.create! | ||
user.save | ||
sign_in user | ||
end | ||
|
||
describe 'response' do | ||
subject { response } | ||
it { should be_success } | ||
end | ||
describe "GET 'index'" do | ||
before do | ||
@foo = create(:revision, hash_code: 'foo') | ||
@bar = create(:revision, hash_code: 'bar') | ||
@baz = create(:revision, hash_code: 'baz') | ||
get 'index' | ||
end | ||
|
||
describe 'response' do | ||
subject { response } | ||
it { should be_success } | ||
end | ||
|
||
describe 'revisions' do | ||
subject { assigns(:revisions) } | ||
describe 'revisions' do | ||
subject { assigns(:revisions) } | ||
|
||
it { should_not be_empty } | ||
it { should include(@foo,@bar,@baz) } | ||
it { should_not be_empty } | ||
it { should include(@foo,@bar,@baz) } | ||
end | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,27 @@ | ||
require 'spec_helper' | ||
|
||
describe WelcomeController do | ||
|
||
describe "GET 'index'" do | ||
it "returns http success" do | ||
get 'index' | ||
response.should be_success | ||
context "not sign in" do | ||
describe "GET 'index'" do | ||
it "returns http success" do | ||
get 'index' | ||
response.should be_success | ||
end | ||
end | ||
end | ||
|
||
context "user sign in" do | ||
describe "GET 'index'" do | ||
before do | ||
user = User.create! | ||
user.save | ||
sign_in user | ||
end | ||
|
||
it "returns http success" do | ||
get 'index' | ||
response.should redirect_to(dashboard_path) | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.