Skip to content

Commit 58bac3b

Browse files
committed
rspec passes cleanly now
1 parent d5598f3 commit 58bac3b

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

app/models/user.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ def to_builder(builder = nil)
134134
builder.pro(self.pro?)
135135

136136
# Assocations.
137-
# I tried doing a nice send(), but Jbuilder freaks out for some reason.
138-
builder.accounts(accounts) {|json, account| account.to_builder(json)}
139-
builder.notifications(notifications) {|json, notification| notification.to_builder(json)}
137+
builder.accounts(accounts) {|account| account.to_builder(builder)}
138+
builder.notifications(notifications) {|notification| notification.to_builder(builder)}
140139

141140
builder
142141
end

spec/controllers/esdb_controller_spec.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
describe EsdbController do
44
describe :callback do
55
it 'should identify and update a replay by esdb job id for replay_progress' do
6+
if Rails.configuration.s3['replays']['access_key_id'] == 'YOUR_ACCESS_KEY'
7+
pending("can't test this without configuring Amazon S3")
8+
end
9+
610
replay = FactoryGirl.create(:replay)
711
replay.uploaded!
812

@@ -18,6 +22,10 @@
1822
end
1923

2024
it 'should identify and update a replay by esdb job id for replay_error' do
25+
if Rails.configuration.s3['replays']['access_key_id'] == 'YOUR_ACCESS_KEY'
26+
pending("can't test this without configuring Amazon S3")
27+
end
28+
2129
replay = FactoryGirl.create(:replay)
2230
replay.uploaded!
2331

@@ -29,6 +37,10 @@
2937

3038
# TODO: might want a replay_done callback or something instead, not sure yet.
3139
it 'should set the replay status to parsing/done when progress reaches 100%' do
40+
if Rails.configuration.s3['replays']['access_key_id'] == 'YOUR_ACCESS_KEY'
41+
pending("can't test this without configuring Amazon S3")
42+
end
43+
3244
replay = FactoryGirl.create(:replay)
3345
replay.uploaded!
3446

@@ -38,4 +50,4 @@
3850
replay.state.should == 'done'
3951
end
4052
end
41-
end
53+
end

spec/controllers/replays_controller_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
# about uploads, we never want them to fail.
2222
# TODO: add tests that demonstrate this better (duplicate replays, etc.)
2323
it 'should create the replay' do
24+
if Rails.configuration.s3['replays']['access_key_id'] == 'YOUR_ACCESS_KEY'
25+
pending("can't test this without configuring Amazon S3")
26+
end
27+
2428
post :drop, :replay => Rack::Test::UploadedFile.new(@replay_file)
2529

2630
response.status.should == 201 # created
@@ -34,6 +38,10 @@
3438
# the upload has been a success and inform the user we're not waiting to
3539
# process the replay.
3640
it 'should create the replay with 100% progress' do
41+
if Rails.configuration.s3['replays']['access_key_id'] == 'YOUR_ACCESS_KEY'
42+
pending("can't test this without configuring Amazon S3")
43+
end
44+
3745
post :drop, :replay => Rack::Test::UploadedFile.new(@replay_file)
3846

3947
response.status.should == 201 # created

spec/models/user_spec.rb

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,19 @@
88
it 'should serialize via jbuilder correctly' do
99
expected_keys = [:email, :password, :password_confirmation, :remember_me, :handle]
1010

11-
user = User.new
11+
user = FactoryGirl.create(:user)
1212
hash = user.to_builder.attributes!
1313

1414
expected_keys.each do |xk|
1515
hash[xk.to_s].should == user.send(xk)
1616
end
17-
17+
1818
hash['accounts'].should_not be_nil
19-
# hash['replays'].should_not be_nil
2019
hash['notifications'].should_not be_nil
21-
end
2220

23-
# Handle not required/used anymore currentl
24-
25-
# it 'should require a handle' do
26-
# user = User.new
27-
# user.handle = nil
28-
# user.valid?.should == false
29-
# end
30-
31-
# it 'should validate the handle to be alphanumeric, mostly' do
32-
# user = FactoryGirl.build(:user)
33-
#
34-
# user.handle = 'EG_IdrA2012'
35-
# user.valid?.should == true
36-
#
37-
# user.handle = 'I pwnz Whitespace'
38-
# user.valid?.should == false
39-
#
40-
# user.handle = 'WHO$)§WOULD%/§DO*THIS*?'
41-
# user.valid?.should == false
42-
# end
21+
hash['accounts'][0].keys.length.should == 23
22+
hash['notifications'][0].keys.length.should == 6
23+
end
4324

4425
it 'should require an email' do
4526
user = User.new

0 commit comments

Comments
 (0)