Commit f5b88710ea79463a5f353e6df9911b34c58fac14
Exists in
spb-stable
and in
2 other branches
Merge branch 'tests_for_fog' into 'master'
Tests for fog
Showing
4 changed files
with
20 additions
and
3 deletions
Show diff stats
Gemfile
| ... | ... | @@ -71,6 +71,7 @@ gem "carrierwave" |
| 71 | 71 | |
| 72 | 72 | # for aws storage |
| 73 | 73 | gem "fog", "~> 1.14", group: :aws |
| 74 | +gem "unf", group: :aws | |
| 74 | 75 | |
| 75 | 76 | # Authorization |
| 76 | 77 | gem "six" |
| ... | ... | @@ -232,4 +233,4 @@ end |
| 232 | 233 | |
| 233 | 234 | group :production do |
| 234 | 235 | gem "gitlab_meta", '6.0' |
| 235 | -end | |
| 236 | 236 | \ No newline at end of file |
| 237 | +end | ... | ... |
Gemfile.lock
| ... | ... | @@ -531,6 +531,9 @@ GEM |
| 531 | 531 | execjs (>= 0.3.0) |
| 532 | 532 | json (>= 1.8.0) |
| 533 | 533 | underscore-rails (1.4.4) |
| 534 | + unf (0.1.4) | |
| 535 | + unf_ext | |
| 536 | + unf_ext (0.0.6) | |
| 534 | 537 | unicorn (4.6.3) |
| 535 | 538 | kgio (~> 2.6) |
| 536 | 539 | rack |
| ... | ... | @@ -659,6 +662,7 @@ DEPENDENCIES |
| 659 | 662 | turbolinks |
| 660 | 663 | uglifier |
| 661 | 664 | underscore-rails (~> 1.4.4) |
| 665 | + unf | |
| 662 | 666 | unicorn (~> 4.6.3) |
| 663 | 667 | unicorn-worker-killer |
| 664 | 668 | version_sorter | ... | ... |
config/initializers/carrierwave.rb
| ... | ... | @@ -18,4 +18,16 @@ if File.exists?(aws_file) |
| 18 | 18 | config.fog_authenticated_url_expiration = 1 << 29 # optional time (in seconds) that authenticated urls will be valid. |
| 19 | 19 | # when fog_public is false and provider is AWS or Google, defaults to 600 |
| 20 | 20 | end |
| 21 | + | |
| 22 | + # Mocking Fog requests, based on: https://github.com/carrierwaveuploader/carrierwave/wiki/How-to%3A-Test-Fog-based-uploaders | |
| 23 | + if Rails.env.test? | |
| 24 | + Fog.mock! | |
| 25 | + connection = ::Fog::Storage.new( | |
| 26 | + :aws_access_key_id => AWS_CONFIG['access_key_id'], | |
| 27 | + :aws_secret_access_key => AWS_CONFIG['secret_access_key'], | |
| 28 | + :provider => 'AWS', | |
| 29 | + :region => AWS_CONFIG['region'] | |
| 30 | + ) | |
| 31 | + connection.directories.create(:key => AWS_CONFIG['bucket']) | |
| 32 | + end | |
| 21 | 33 | end | ... | ... |
spec/helpers/application_helper_spec.rb
| ... | ... | @@ -46,7 +46,7 @@ describe ApplicationHelper do |
| 46 | 46 | group = create(:group) |
| 47 | 47 | group.avatar = File.open(avatar_file_path) |
| 48 | 48 | group.save! |
| 49 | - group_icon(group.path).to_s.should == "/uploads/group/avatar/#{ group.id }/gitlab_logo.png" | |
| 49 | + group_icon(group.path).to_s.should match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png") | |
| 50 | 50 | end |
| 51 | 51 | |
| 52 | 52 | it "should give default avatar_icon when no avatar is present" do |
| ... | ... | @@ -63,7 +63,7 @@ describe ApplicationHelper do |
| 63 | 63 | user = create(:user) |
| 64 | 64 | user.avatar = File.open(avatar_file_path) |
| 65 | 65 | user.save! |
| 66 | - avatar_icon(user.email).to_s.should == "/uploads/user/avatar/#{ user.id }/gitlab_logo.png" | |
| 66 | + avatar_icon(user.email).to_s.should match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png") | |
| 67 | 67 | end |
| 68 | 68 | |
| 69 | 69 | it "should call gravatar_icon when no avatar is present" do | ... | ... |