summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-04-24 17:01:49 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-04-24 17:01:49 +0000
commitf5b88710ea79463a5f353e6df9911b34c58fac14 (patch)
tree914f15f0854987053f09659787d51710286f5cdc
parent1feaa336edf7a16ca39b036345890f05d35a1463 (diff)
parentfe1ca616017633a243017ad265c4713aca773ea3 (diff)
downloadgitlab-ce-f5b88710ea79463a5f353e6df9911b34c58fac14.tar.gz
Merge branch 'tests_for_fog' into 'master'
Tests for fog
-rw-r--r--Gemfile3
-rw-r--r--Gemfile.lock4
-rw-r--r--config/initializers/carrierwave.rb12
-rw-r--r--spec/helpers/application_helper_spec.rb4
4 files changed, 20 insertions, 3 deletions
diff --git a/Gemfile b/Gemfile
index 4ab1ab50eb9..7372d244725 100644
--- a/Gemfile
+++ b/Gemfile
@@ -71,6 +71,7 @@ gem "carrierwave"
# for aws storage
gem "fog", "~> 1.14", group: :aws
+gem "unf", group: :aws
# Authorization
gem "six"
@@ -232,4 +233,4 @@ end
group :production do
gem "gitlab_meta", '6.0'
-end \ No newline at end of file
+end
diff --git a/Gemfile.lock b/Gemfile.lock
index 155e03e5456..0556b870be5 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -531,6 +531,9 @@ GEM
execjs (>= 0.3.0)
json (>= 1.8.0)
underscore-rails (1.4.4)
+ unf (0.1.4)
+ unf_ext
+ unf_ext (0.0.6)
unicorn (4.6.3)
kgio (~> 2.6)
rack
@@ -659,6 +662,7 @@ DEPENDENCIES
turbolinks
uglifier
underscore-rails (~> 1.4.4)
+ unf
unicorn (~> 4.6.3)
unicorn-worker-killer
version_sorter
diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb
index 6875fa74edd..d0065b63e54 100644
--- a/config/initializers/carrierwave.rb
+++ b/config/initializers/carrierwave.rb
@@ -18,4 +18,16 @@ if File.exists?(aws_file)
config.fog_authenticated_url_expiration = 1 << 29 # optional time (in seconds) that authenticated urls will be valid.
# when fog_public is false and provider is AWS or Google, defaults to 600
end
+
+ # Mocking Fog requests, based on: https://github.com/carrierwaveuploader/carrierwave/wiki/How-to%3A-Test-Fog-based-uploaders
+ if Rails.env.test?
+ Fog.mock!
+ connection = ::Fog::Storage.new(
+ :aws_access_key_id => AWS_CONFIG['access_key_id'],
+ :aws_secret_access_key => AWS_CONFIG['secret_access_key'],
+ :provider => 'AWS',
+ :region => AWS_CONFIG['region']
+ )
+ connection.directories.create(:key => AWS_CONFIG['bucket'])
+ end
end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 61c561335e5..0376e0aadf0 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -46,7 +46,7 @@ describe ApplicationHelper do
group = create(:group)
group.avatar = File.open(avatar_file_path)
group.save!
- group_icon(group.path).to_s.should == "/uploads/group/avatar/#{ group.id }/gitlab_logo.png"
+ group_icon(group.path).to_s.should match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png")
end
it "should give default avatar_icon when no avatar is present" do
@@ -63,7 +63,7 @@ describe ApplicationHelper do
user = create(:user)
user.avatar = File.open(avatar_file_path)
user.save!
- avatar_icon(user.email).to_s.should == "/uploads/user/avatar/#{ user.id }/gitlab_logo.png"
+ avatar_icon(user.email).to_s.should match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
end
it "should call gravatar_icon when no avatar is present" do