Commit fe1ca616017633a243017ad265c4713aca773ea3
1 parent
1feaa336
Exists in
spb-stable
and in
2 other branches
Make sure that tests pass when aws group is used.
Showing
4 changed files
with
20 additions
and
3 deletions
Show diff stats
Gemfile
| @@ -71,6 +71,7 @@ gem "carrierwave" | @@ -71,6 +71,7 @@ gem "carrierwave" | ||
| 71 | 71 | ||
| 72 | # for aws storage | 72 | # for aws storage |
| 73 | gem "fog", "~> 1.14", group: :aws | 73 | gem "fog", "~> 1.14", group: :aws |
| 74 | +gem "unf", group: :aws | ||
| 74 | 75 | ||
| 75 | # Authorization | 76 | # Authorization |
| 76 | gem "six" | 77 | gem "six" |
| @@ -232,4 +233,4 @@ end | @@ -232,4 +233,4 @@ end | ||
| 232 | 233 | ||
| 233 | group :production do | 234 | group :production do |
| 234 | gem "gitlab_meta", '6.0' | 235 | gem "gitlab_meta", '6.0' |
| 235 | -end | ||
| 236 | \ No newline at end of file | 236 | \ No newline at end of file |
| 237 | +end |
Gemfile.lock
| @@ -531,6 +531,9 @@ GEM | @@ -531,6 +531,9 @@ GEM | ||
| 531 | execjs (>= 0.3.0) | 531 | execjs (>= 0.3.0) |
| 532 | json (>= 1.8.0) | 532 | json (>= 1.8.0) |
| 533 | underscore-rails (1.4.4) | 533 | underscore-rails (1.4.4) |
| 534 | + unf (0.1.4) | ||
| 535 | + unf_ext | ||
| 536 | + unf_ext (0.0.6) | ||
| 534 | unicorn (4.6.3) | 537 | unicorn (4.6.3) |
| 535 | kgio (~> 2.6) | 538 | kgio (~> 2.6) |
| 536 | rack | 539 | rack |
| @@ -659,6 +662,7 @@ DEPENDENCIES | @@ -659,6 +662,7 @@ DEPENDENCIES | ||
| 659 | turbolinks | 662 | turbolinks |
| 660 | uglifier | 663 | uglifier |
| 661 | underscore-rails (~> 1.4.4) | 664 | underscore-rails (~> 1.4.4) |
| 665 | + unf | ||
| 662 | unicorn (~> 4.6.3) | 666 | unicorn (~> 4.6.3) |
| 663 | unicorn-worker-killer | 667 | unicorn-worker-killer |
| 664 | version_sorter | 668 | version_sorter |
config/initializers/carrierwave.rb
| @@ -18,4 +18,16 @@ if File.exists?(aws_file) | @@ -18,4 +18,16 @@ if File.exists?(aws_file) | ||
| 18 | config.fog_authenticated_url_expiration = 1 << 29 # optional time (in seconds) that authenticated urls will be valid. | 18 | config.fog_authenticated_url_expiration = 1 << 29 # optional time (in seconds) that authenticated urls will be valid. |
| 19 | # when fog_public is false and provider is AWS or Google, defaults to 600 | 19 | # when fog_public is false and provider is AWS or Google, defaults to 600 |
| 20 | end | 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 | end | 33 | end |
spec/helpers/application_helper_spec.rb
| @@ -46,7 +46,7 @@ describe ApplicationHelper do | @@ -46,7 +46,7 @@ describe ApplicationHelper do | ||
| 46 | group = create(:group) | 46 | group = create(:group) |
| 47 | group.avatar = File.open(avatar_file_path) | 47 | group.avatar = File.open(avatar_file_path) |
| 48 | group.save! | 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 | end | 50 | end |
| 51 | 51 | ||
| 52 | it "should give default avatar_icon when no avatar is present" do | 52 | it "should give default avatar_icon when no avatar is present" do |
| @@ -63,7 +63,7 @@ describe ApplicationHelper do | @@ -63,7 +63,7 @@ describe ApplicationHelper do | ||
| 63 | user = create(:user) | 63 | user = create(:user) |
| 64 | user.avatar = File.open(avatar_file_path) | 64 | user.avatar = File.open(avatar_file_path) |
| 65 | user.save! | 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 | end | 67 | end |
| 68 | 68 | ||
| 69 | it "should call gravatar_icon when no avatar is present" do | 69 | it "should call gravatar_icon when no avatar is present" do |