Skip to content

Commit 6ed72bb

Browse files
committed
Merge pull request coderwall#125 from sirwolfgang/tests
Tests
2 parents bda636c + 5f243fb commit 6ed72bb

24 files changed

+6487
-272
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ WEB_MAX_CONCURRENCY=16
2424
WEB_WORKERS=8
2525
WEB_PORT=tcp://0.0.0.0:3000
2626

27+
# VCR record mode should only be touched if your adding to or updating api backed tests.
28+
# VCR_RECORD_MODE=none #Modes: [new, once, all]
29+
2730
############### API KEYS ###############
2831

2932
# GitHub User

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ vagrant/coderwall-box/output-virtualbox-iso/
4949
vagrant/coderwall-box/packer_cache/
5050
vagrant/coderwall-box/packer_virtualbox-iso_virtualbox.box
5151
vagrant/dotfiles
52-
vcr_cassettes
5352
erd.pdf
5453
vagrant.yml
5554
git_stats

Rakefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
require File.expand_path('../config/application', __FILE__)
22
require 'rake'
3+
require 'rspec/core/rake_task'
34

45
Coderwall::Application.load_tasks
56

7+
task default: :spec
8+
69
puts "RAILS_ENV=#{Rails.env}"

app/models/github_badge.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# TODO: Refactor API Calls to Sidekiq Workers
2+
# TODO: Verify that GITHUB_ADMIN_USER is required, and can't be replaced with app based auth
3+
# TODO: Refactor/Reflow Error Handling, Don't rescue fail. Defer to sidekiq job auto retry
14
class GithubBadge
25
def initialize
36
@client = Octokit::Client.new(

spec/controllers/accounts_controller_spec.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
let(:plan) { Plan.create(amount: 20000, interval: Plan::MONTHLY, name: 'Monthly') }
44
let(:current_user) { Fabricate(:user) }
55

6-
before {
6+
before do
77
team.add_user(current_user)
88
controller.send :sign_in, current_user
9-
}
9+
end
1010

1111
def new_token
1212
Stripe::Token.create(card: { number: 4242424242424242, cvc: 224, exp_month: 12, exp_year: 14 }).try(:id)
@@ -20,9 +20,14 @@ def valid_params
2020
end
2121

2222
it 'should create an account and send email' do
23-
post :create, { team_id: team.id, account: valid_params }
24-
expect(ActionMailer::Base.deliveries.size).to eq(1)
25-
expect(ActionMailer::Base.deliveries.first.body.encoded).to include(team.name)
26-
expect(ActionMailer::Base.deliveries.first.body.encoded).to include(plan.name)
23+
# TODO: Refactor API call to Sidekiq Job
24+
VCR.use_cassette('AccountsController') do
25+
26+
post :create, { team_id: team.id, account: valid_params }
27+
expect(ActionMailer::Base.deliveries.size).to eq(1)
28+
expect(ActionMailer::Base.deliveries.first.body.encoded).to include(team.name)
29+
expect(ActionMailer::Base.deliveries.first.body.encoded).to include(plan.name)
30+
31+
end
2732
end
2833
end

0 commit comments

Comments
 (0)