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
1 parent
e354dd1
commit 7756e3d
Showing
25 changed files
with
186 additions
and
129 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
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,15 @@ | ||
require 'spec_helper' | ||
|
||
describe HomeController do | ||
describe '#index' do | ||
let(:subject) { get :index } | ||
|
||
it 'renders index template' do | ||
expect(subject).to render_template :index | ||
end | ||
|
||
it 'returns 200 status code' do | ||
expect(subject.status).to eq 200 | ||
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,40 @@ | ||
require 'spec_helper' | ||
|
||
describe ProjectsController do | ||
describe '#index' do | ||
let(:subject) { get :index } | ||
before do | ||
allow(Project).to receive(:order).with(available_amount_cache: :desc, watchers_count: :desc, full_name: :asc).and_return(Project) | ||
allow(Project).to receive(:page).with(nil).and_return(Project) | ||
allow(Project).to receive(:per).with(30).and_return(Project) | ||
end | ||
|
||
it 'renders index template' do | ||
expect(subject).to render_template :index | ||
end | ||
|
||
it 'returns 200 status code' do | ||
expect(subject.status).to eq 200 | ||
end | ||
|
||
it 'Project calls order' do | ||
expect(Project).to receive(:order).with(available_amount_cache: :desc, watchers_count: :desc, full_name: :asc).and_return(Project) | ||
subject | ||
end | ||
|
||
it 'Project calls page' do | ||
expect(Project).to receive(:page).with(nil).and_return(Project) | ||
subject | ||
end | ||
|
||
it 'Project calls per' do | ||
expect(Project).to receive(:per).with(30).and_return(Project) | ||
subject | ||
end | ||
|
||
it 'assigns @projects' do | ||
subject | ||
expect(assigns[:projects].name).to eq 'Project' | ||
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,61 @@ | ||
require 'spec_helper' | ||
|
||
describe UsersController do | ||
describe '#show' do | ||
let(:user) { mock_model User, id: 100000000 } | ||
let(:subject) { get :show, id: user.id } | ||
|
||
context 'when logged in' do | ||
login_user | ||
|
||
context 'when user found' do | ||
context 'when viewing own page' do | ||
before { allow(user).to receive(:id).and_return(@current_user.id) } | ||
it 'renders show template' do | ||
expect(subject).to render_template :show | ||
end | ||
|
||
it 'returns 200 status code' do | ||
expect(subject.status).to eq 200 | ||
end | ||
end | ||
|
||
context 'when viewing other\'s page' do | ||
let(:new_user) { create(:user) } | ||
let(:subject) { get :show, id: new_user.id } | ||
|
||
it 'redirect to root_path' do | ||
expect(subject).to redirect_to root_path | ||
end | ||
|
||
it 'sets flash error message' do | ||
subject | ||
expect(flash[:error]).to eq('You are not authorized to perform this action!') | ||
end | ||
end | ||
end | ||
|
||
context 'when user not found' do | ||
it 'redirect to root_path' do | ||
expect(subject).to redirect_to root_path | ||
end | ||
|
||
it 'sets flash error message' do | ||
subject | ||
expect(flash[:error]).to eq('User not found.') | ||
end | ||
end | ||
end | ||
|
||
context 'when not logged in' do | ||
it 'redirects to login page' do | ||
expect(subject).to redirect_to new_user_session_path | ||
end | ||
|
||
it 'sets flash alert message' do | ||
subject | ||
expect(flash[:alert]).to eq('You need to sign in or sign up before continuing.') | ||
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,30 @@ | ||
require 'spec_helper' | ||
|
||
describe UserMailer do | ||
describe 'new_tip' do | ||
let(:user) { mock_model User, name: 'kd', email: 'kd.engineer@yahoo.co.in', full_name: 'kuldeep aggarwal', login_token: 'my login token', balance: 10 } | ||
let(:project) { mock_model Project, full_name: 'logger-extension' } | ||
let(:tip) { mock_model Tip, amount: 0.0001, project: project } | ||
let(:mail) { UserMailer.new_tip(user, tip) } | ||
|
||
it 'renders the subject' do | ||
expect(mail.subject).to eq 'You received a tip for your commit' | ||
end | ||
|
||
it 'renders the receiver email' do | ||
expect(mail.to).to eq [user.email] | ||
end | ||
|
||
it 'renders the sender email' do | ||
expect(mail.from).to eq ['no-reply@tip4commit.com'] | ||
end | ||
|
||
it 'assigns user\'s full_name' do | ||
expect(mail.body.encoded).to match(user.full_name) | ||
end | ||
|
||
it 'assigns users\' balance' do | ||
expect(mail.body.encoded).to match("Please, log in and tell us your bitcoin address to get it.</p>\r\n<p>Your current balance is <nobr>0.00000010 Ƀ</nobr>") | ||
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,27 @@ | ||
require 'spec_helper' | ||
|
||
describe User do | ||
let(:user) { create(:user) } | ||
|
||
describe 'full_name' do | ||
context 'when name is present' do | ||
it 'returns name' do | ||
expect(user.full_name).to eq(user.name) | ||
end | ||
end | ||
|
||
context 'when name is absent and nickname is present' do | ||
it 'returns nickname' do | ||
user.name = nil | ||
expect(user.full_name).to eq(user.nickname) | ||
end | ||
end | ||
|
||
context 'when name and nickname is absent and email is absent' do | ||
it 'returns email' do | ||
user.name = user.nickname = nil | ||
expect(user.full_name).to eq(user.email) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module ControllerMacros | ||
def login_user | ||
before do | ||
@request.env['devise.mapping'] = Devise.mappings[:user] | ||
@current_user = create(:user) | ||
sign_in @current_user | ||
end | ||
end | ||
end |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.