summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--app/controllers/projects_controller.rb13
-rw-r--r--app/services/projects/image_service.rb39
-rw-r--r--app/uploaders/file_uploader.rb2
-rw-r--r--config/gitlab.yml.example2
-rw-r--r--doc/release/monthly.md13
-rw-r--r--spec/controllers/commits_controller_spec.rb2
-rw-r--r--spec/controllers/projects_controller_spec.rb19
-rw-r--r--spec/services/projects/image_service_spec.rb65
9 files changed, 138 insertions, 19 deletions
diff --git a/README.md b/README.md
index cbbfebc81ef..283336b9e4d 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,8 @@
* [Cloud 66 deployment and management](http://blog.cloud66.com/installing-gitlab-ubuntu/) Use Cloud 66 to deploy GitLab to your own server or any cloud (eg. DigitalOcean, AWS, Rackspace, GCE) and then manage it with database backups, scaling and more.
+* [Pkgr.io one-click installer](https://pkgr.io/apps/gitlabhq/gitlabhq) Currently supporting Ubuntu 14.04, Ubuntu 12.04 and Debian 7.4. For more information check the [README](https://gitlab.com/gitlab-org/gitlab-recipes/blob/master/install/pkgr/README.md) at gitlab-recipes repo.
+
#### Unofficial installation methods
* [GitLab recipes](https://gitlab.com/gitlab-org/gitlab-recipes/) repository with unofficial guides for using GitLab with different software (operating systems, webservers, etc.) than the official version.
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index c15205fb68f..07ccbd57faf 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -163,13 +163,14 @@ class ProjectsController < ApplicationController
end
def upload_image
- uploader = FileUploader.new('uploads', upload_path, accepted_images)
- alt = params['markdown_img'].original_filename
- uploader.store!(params['markdown_img'])
- link = { 'alt' => File.basename(alt, '.*'),
- 'url' => File.join(root_url, uploader.url) }
+ link_to_image = ::Projects::ImageService.new(repository, params, root_url).execute
+
respond_to do |format|
- format.json { render json: { link: link } }
+ if link_to_image
+ format.json { render json: { link: link_to_image } }
+ else
+ format.json { render json: "Invalid file.", status: :unprocessable_entity }
+ end
end
end
diff --git a/app/services/projects/image_service.rb b/app/services/projects/image_service.rb
new file mode 100644
index 00000000000..c79ddddd972
--- /dev/null
+++ b/app/services/projects/image_service.rb
@@ -0,0 +1,39 @@
+module Projects
+ class ImageService < BaseService
+ include Rails.application.routes.url_helpers
+ def initialize(repository, params, root_url)
+ @repository, @params, @root_url = repository, params.dup, root_url
+ end
+
+ def execute
+ uploader = FileUploader.new('uploads', upload_path, accepted_images)
+ image = @params['markdown_img']
+
+ if image && correct_mime_type?(image)
+ alt = image.original_filename
+ uploader.store!(image)
+ link = {
+ 'alt' => File.basename(alt, '.*'),
+ 'url' => File.join(@root_url, uploader.url)
+ }
+ else
+ link = nil
+ end
+ end
+
+ protected
+
+ def upload_path
+ base_dir = FileUploader.generate_dir
+ File.join(@repository.path_with_namespace, base_dir)
+ end
+
+ def accepted_images
+ %w(png jpg jpeg gif)
+ end
+
+ def correct_mime_type?(image)
+ accepted_images.map{ |format| image.content_type.include? format }.any?
+ end
+ end
+end
diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb
index cbc9271ac14..0fa987c93f6 100644
--- a/app/uploaders/file_uploader.rb
+++ b/app/uploaders/file_uploader.rb
@@ -25,7 +25,7 @@ class FileUploader < CarrierWave::Uploader::Base
end
def store!(file)
- file.original_filename = self.class.generate_filename(file)
+ @filename = self.class.generate_filename(file)
super
end
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index 7b53a065533..04e85ed9a9d 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -38,6 +38,8 @@ production: &base
# Email address of your support contact (default: same as email_from)
support_email: support@example.com
+ # Email server smtp settings are in [a separate file](initializers/smtp_settings.rb.sample).
+
## User settings
default_projects_limit: 10
# default_can_create_group: false # default: true
diff --git a/doc/release/monthly.md b/doc/release/monthly.md
index ed580f666ac..c9239a7398d 100644
--- a/doc/release/monthly.md
+++ b/doc/release/monthly.md
@@ -120,7 +120,7 @@ It is important to do this as soon as possible, so we can catch any errors befor
Create issue on dev.gitlab.org gitlab repository, named "GitLab X.X release" in order to keep track of the progress.
-Use the omnibus packages or cookbook to test using [this guide](https://dev.gitlab.org/gitlab/gitlab-ee/blob/master/doc/release/manual_testing.md).
+Use the omnibus packages of Enterprise Edition using [this guide](https://dev.gitlab.org/gitlab/gitlab-ee/blob/master/doc/release/manual_testing.md).
**NOTE** Upgrader can only be tested when tags are pushed to all repositories. Do not forget to confirm it is working before releasing. Note that in the issue.
@@ -201,6 +201,17 @@ Include a link to the blog post and keep it short.
Proposed email for CE: "We have released a new version of GitLab Community Edition and its packages. See our blog post(<link>) for more information."
+### **10. Create a regressions issue**
+
+On [the GitLab CE issue tracker on GitLab.com](https://gitlab.com/gitlab-org/gitlab-ce/issues/) create an issue titled "GitLab X.X regressions" add the following text:
+
+This is a meta issue to discuss possible regressions in this monthly release and any patch versions.
+Please do not raise issues directly in this issue but link to issues that might warrant a patch release.
+The decision to create a patch release or not is with the release manager who is assigned to this issue.
+The release manager will comment here about the plans for patch releases.
+
+Assign the issue to the release manager and /cc all the core-team members active on the issue tracker. If there are any known bugs in the release add them immediately.
+
# **23rd - Optional Patch Release**
# **24th - Update GitLab.com**
diff --git a/spec/controllers/commits_controller_spec.rb b/spec/controllers/commits_controller_spec.rb
index 308cfa69219..0c19d755eb1 100644
--- a/spec/controllers/commits_controller_spec.rb
+++ b/spec/controllers/commits_controller_spec.rb
@@ -6,7 +6,7 @@ describe Projects::CommitsController do
before do
sign_in(user)
- project.creator = user
+ project.team << [user, :master]
end
describe "GET show" do
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 07ca8d25026..944df5314bd 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -3,42 +3,41 @@ require('spec_helper')
describe ProjectsController do
let(:project) { create(:project) }
let(:user) { create(:user) }
- let(:png) { fixture_file_upload(Rails.root + 'spec/fixtures/dk.png', 'image/png') }
let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') }
- let(:gif) { fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') }
let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') }
describe "POST #upload_image" do
before do
sign_in(user)
+ project.team << [user, :developer]
end
context "without params['markdown_img']" do
it "returns an error" do
- post :upload_image, id: project.to_param
- expect(response.status).to eq(404)
+ post :upload_image, id: project.to_param, format: :json
+ expect(response.status).to eq(422)
end
end
context "with invalid file" do
before do
- post :upload_image, id: project.to_param, markdown_img: @img
+ post :upload_image, id: project.to_param, markdown_img: txt, format: :json
end
it "returns an error" do
- expect(response.status).to eq(404)
+ expect(response.status).to eq(422)
end
end
context "with valid file" do
before do
- post :upload_image, id: project.to_param, markdown_img: @img
+ post :upload_image, id: project.to_param, markdown_img: jpg, format: :json
end
it "returns a content with original filename and new link." do
- link = { alt: 'rails_sample', link: '' }.to_json
- expect(response.body).to have_content link
+ expect(response.body).to match "\"alt\":\"rails_sample\""
+ expect(response.body).to match "\"url\":\"http://test.host/uploads/#{project.path_with_namespace}"
end
end
end
-end \ No newline at end of file
+end
diff --git a/spec/services/projects/image_service_spec.rb b/spec/services/projects/image_service_spec.rb
new file mode 100644
index 00000000000..070c21698cf
--- /dev/null
+++ b/spec/services/projects/image_service_spec.rb
@@ -0,0 +1,65 @@
+require 'spec_helper'
+
+describe Projects::ImageService do
+ before(:each) { enable_observers }
+ after(:each) { disable_observers }
+
+ describe 'Image service' do
+ before do
+ @user = create :user
+ @project = create :project, creator_id: @user.id, namespace: @user.namespace
+ end
+
+ context 'for valid gif file' do
+ before do
+ gif = fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif')
+ @link_to_image = upload_image(@project.repository, { 'markdown_img' => gif }, "http://test.example/")
+ end
+
+ it { expect(@link_to_image).to have_key("alt") }
+ it { expect(@link_to_image).to have_key("url") }
+ it { expect(@link_to_image).to have_value("banana_sample") }
+ it { expect(@link_to_image["url"]).to match("http://test.example/uploads/#{@project.path_with_namespace}") }
+ it { expect(@link_to_image["url"]).to match("banana_sample.gif") }
+ end
+
+ context 'for valid png file' do
+ before do
+ png = fixture_file_upload(Rails.root + 'spec/fixtures/dk.png', 'image/png')
+ @link_to_image = upload_image(@project.repository, { 'markdown_img' => png }, "http://test.example/")
+ end
+
+ it { expect(@link_to_image).to have_key("alt") }
+ it { expect(@link_to_image).to have_key("url") }
+ it { expect(@link_to_image).to have_value("dk") }
+ it { expect(@link_to_image["url"]).to match("http://test.example/uploads/#{@project.path_with_namespace}") }
+ it { expect(@link_to_image["url"]).to match("dk.png") }
+ end
+
+ context 'for valid jpg file' do
+ before do
+ jpg = fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg')
+ @link_to_image = upload_image(@project.repository, { 'markdown_img' => jpg }, "http://test.example/")
+ end
+
+ it { expect(@link_to_image).to have_key("alt") }
+ it { expect(@link_to_image).to have_key("url") }
+ it { expect(@link_to_image).to have_value("rails_sample") }
+ it { expect(@link_to_image["url"]).to match("http://test.example/uploads/#{@project.path_with_namespace}") }
+ it { expect(@link_to_image["url"]).to match("rails_sample.jpg") }
+ end
+
+ context 'for txt file' do
+ before do
+ txt = fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain')
+ @link_to_image = upload_image(@project.repository, { 'markdown_img' => txt }, "http://test.example/")
+ end
+
+ it { expect(@link_to_image).to be_nil }
+ end
+ end
+
+ def upload_image(repository, params, root_url)
+ Projects::ImageService.new(repository, params, root_url).execute
+ end
+end