forked from dsjoerg/ggtracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplays_controller_spec.rb
More file actions
48 lines (38 loc) · 1.67 KB
/
replays_controller_spec.rb
File metadata and controls
48 lines (38 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'spec_helper'
describe ReplaysController do
before(:all) do
@replay_file = File.new(File.join(Rails.root, 'spec/files/test.SC2Replay'))
end
# We could've used #create, but I would like to reserve create for manual
# upload via a form if necessary. Drop never sees any user interaction and
# never has to render back HTML.
describe :drop do
it 'should return error if no file given' do
post :drop
response.should_not be_ok
response.body.should_not be_empty
# JSON.parse(last_response.body).should == {'status' => 'error', 'error' => 'File missing'}
end
# It should always create the Replay object because we're very optimistic
# about uploads, we never want them to fail.
# TODO: add tests that demonstrate this better (duplicate replays, etc.)
it 'should create the replay' do
if Rails.configuration.s3['replays']['access_key_id'] == 'YOUR_ACCESS_KEY'
pending("can't test this without configuring Amazon S3")
end
post :drop, :replays => [ Rack::Test::UploadedFile.new(@replay_file) ]
response.status.should == 201 # created
response.body.should_not be_empty
replay = Replay.where(:replay_file_name => File.basename(@replay_file.path)).first
replay.should_not == nil
end
it 'should create the replay via s3 drop' do
fname = "01b5b19019ac34499ecbc60ce980b26a.SC2Replay"
post :s3_drop, :file_name => fname, :s3_key => fname, :channel => "testchannel"
response.status.should == 201 # created
response.body.should_not be_empty
replay = Replay.where(:replay_file_name => fname).first
replay.should_not == nil
end
end
end