-
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.
- Loading branch information
Showing
18 changed files
with
150 additions
and
1 deletion.
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
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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class FirmsController < ApplicationController | ||
def index | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class PagesController < ApplicationController | ||
before_action :authenticate, except: [:error] | ||
|
||
def error | ||
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<main role="main"> | ||
<div class="l-constrained"> | ||
<div class="l-constrained__padded"> | ||
<h2>Firms</h2> | ||
</div> | ||
</div> | ||
</main> |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<main role="main"> | ||
<div class="l-constrained"> | ||
<div class="l-constrained__padded"> | ||
<h2>Error</h2> | ||
</div> | ||
</div> | ||
</main> |
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
5 changes: 5 additions & 0 deletions
5
db/migrate/20141222150416_add_last_sign_in_at_to_principal.rb
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddLastSignInAtToPrincipal < ActiveRecord::Migration | ||
def change | ||
add_column :principals, :last_sign_in_at, :datetime | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FactoryGirl.define do | ||
factory :principal do | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
RSpec.feature 'Verify principal e-mail address' do | ||
let(:firms_page) { FirmsPage.new } | ||
|
||
before { Timecop.freeze(Time.local(1990)) } | ||
after { Timecop.return } | ||
|
||
scenario 'when the link in the confirmation e-mail is followed' do | ||
given_i_am_a_verified_principal | ||
when_i_follow_the_customised_link | ||
then_my_email_is_verified | ||
and_i_see_the_firms_page | ||
end | ||
|
||
def given_i_am_a_verified_principal | ||
@principal = FactoryGirl.create(:principal) | ||
end | ||
|
||
def when_i_follow_the_customised_link | ||
firms_page.load(query: {token: @principal.token}) | ||
end | ||
|
||
def then_my_email_is_verified | ||
@principal.reload | ||
|
||
# We use the presence of a last sign-in date as an indication | ||
# that the principal's e-mail address is valid (they received | ||
# a link with their personal token in a confirmation e-mail). | ||
expect(@principal.last_sign_in_at).to eql(Time.now) | ||
end | ||
|
||
def and_i_see_the_firms_page | ||
expect(firms_page).to be_displayed | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
RSpec.describe 'Token Authentication', type: :request do | ||
let(:principal) { FactoryGirl.create(:principal) } | ||
|
||
describe 'GET /firms' do | ||
before do | ||
get firms_path(token: token) | ||
end | ||
|
||
context 'with a valid token' do | ||
let(:token) { principal.token } | ||
|
||
it 'returns 200 response' do | ||
expect(response.status).to be(200) | ||
end | ||
end | ||
|
||
context 'with an invalid token' do | ||
let(:token) { 'invalid-token' } | ||
|
||
it 'returns 302 response' do | ||
expect(response.status).to be(302) | ||
end | ||
|
||
it 'redirects to the error page' do | ||
expect(response).to redirect_to(error_path) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class ErrorPage < SitePrism::Page | ||
set_url '/error' | ||
set_url_matcher /\/error/ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class FirmsPage < SitePrism::Page | ||
set_url '/firms{?query*}' | ||
set_url_matcher /\/firms(:?(\?.*)?)$/ | ||
end |