Skip to content

Commit

Permalink
Merge branch 'upstream' into feature/update_to_7.0
Browse files Browse the repository at this point in the history
* upstream:
  Bump version to 7.0.0
  Remove milestone observer from db fixture.
  Fix permission issue with highest access level for group
  The Wall is deprecated in 7.0
  Create 6.0-to-7.0 update guide
  During release we need to create several update guides
  Fix project trasnfer for admin area
  Revert "Merge branch 'fix-email-threading' into 'master'"

Conflicts:
	app/controllers/admin/projects_controller.rb
	app/mailers/emails/groups.rb
	app/mailers/emails/issues.rb
	app/mailers/emails/merge_requests.rb
	app/mailers/emails/notes.rb
	app/mailers/emails/projects.rb
	app/mailers/notify.rb
	spec/mailers/notify_spec.rb
	spec/services/issues/close_service_spec.rb
	spec/services/issues/update_service_spec.rb
	spec/services/merge_requests/close_service_spec.rb
	spec/services/merge_requests/update_service_spec.rb
  • Loading branch information
zzet committed Jun 20, 2014
2 parents 9333d0a + d1e424b commit 621787d
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 105 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.0.0.rc1
7.0.0
8 changes: 2 additions & 6 deletions app/controllers/admin/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ def destroy
end

def transfer
result = ::ProjectsService.new(current_user, @project, project: params).transfer(:admin)
result = ::ProjectsService.new(current_user, @project, project: params.dup).transfer

if result
redirect_to [:admin, @project]
else
render :show
end
redirect_to [:admin, @project.reload]
end

protected
Expand Down
64 changes: 8 additions & 56 deletions app/mailers/notify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Notify < ActionMailer::Base
default_url_options[:script_name] = Gitlab.config.gitlab.relative_url_root

default from: Proc.new { default_sender_address.format }
default to: Proc.new { project_sender_address.format }
default reply_to: "noreply@#{Gitlab.config.gitlab.host}"

# Just send email with 2 seconds delay
Expand All @@ -28,17 +27,6 @@ def default_sender_address
address
end

# The default email address to send emails to. Includes the project name if possible.
def project_sender_address
if @project
address = default_sender_address
address.display_name = @project.name_with_namespace
address
else
default_sender_address
end
end

# Return an email address that displays the name of the sender.
# Only the displayed name changes; the actual email address is always the same.
def sender(sender_id)
Expand All @@ -60,6 +48,14 @@ def recipient(recipient_id)
end
end

# Set the Message-ID header field
#
# local_part - The local part of the message ID
#
def set_message_id(local_part)
headers["Message-ID"] = "<#{local_part}@#{Gitlab.config.gitlab.host}>"
end

# Set the References header field
#
# local_part - The local part of the referenced message ID
Expand Down Expand Up @@ -92,48 +88,4 @@ def subject(*extra)
subject << extra.join(' | ') if extra.present?
subject
end

# Return a string suitable for inclusion in the 'Message-Id' mail header.
#
# The message-id is generated from the unique URL to a model object.
def message_id(model)
model_name = model.class.model_name.singular_route_key
"<#{model_name}_#{model.id}@#{Gitlab.config.gitlab.host}>"
end

# Send an email that starts a new conversation thread,
# with headers suitable for grouping by thread in email clients.
#
# See: mail_answer_thread
def mail_new_thread(model, headers = {}, &block)
raise ArgumentError, '"To:" header will be overwritten; use "Cc:" or "Bcc:"' unless headers[:to].nil?
headers[:to] = project_sender_address.format

headers['Message-ID'] = message_id(model)

mail(headers, &block)
end

# Send an email that responds to an existing conversation thread,
# with headers suitable for grouping by thread in email clients.
#
# For grouping emails by thread, email clients heuristics require the answers to:
#
# * have a subject that begin by 'Re: '
# * have a 'In-Reply-To' or 'References' header that references the original 'Message-ID'
# * have stable 'From' and 'To' headers between messages of the same thread
#
def mail_answer_thread(model, headers = {}, &block)
raise ArgumentError, '"To:" header will be overwritten; use "Cc:" or "Bcc:"' unless headers[:to].nil?
headers[:to] = project_sender_address.format

headers['In-Reply-To'] = message_id(model)
headers['References'] = message_id(model)

if (headers[:subject])
headers[:subject].prepend('Re: ')
end

mail(headers, &block)
end
end
19 changes: 15 additions & 4 deletions app/models/project_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,30 @@ def import(source_project)
end

def guest?(user)
find_tm(user.id).try(:access_field) == Gitlab::Access::GUEST
max_tm_access(user.id) == Gitlab::Access::GUEST
end

def reporter?(user)
find_tm(user.id).try(:access_field) == Gitlab::Access::REPORTER
max_tm_access(user.id) == Gitlab::Access::REPORTER
end

def developer?(user)
find_tm(user.id).try(:access_field) == Gitlab::Access::DEVELOPER
max_tm_access(user.id) == Gitlab::Access::DEVELOPER
end

def master?(user)
find_tm(user.id).try(:access_field) == Gitlab::Access::MASTER
max_tm_access(user.id) == Gitlab::Access::MASTER
end

def max_tm_access(user_id)
access = []
access << project.users_projects.find_by(user_id: user_id).try(:access_field)

if group
access << group.users_groups.find_by(user_id: user_id).try(:access_field)
end

access.compact.max
end

private
Expand Down
4 changes: 0 additions & 4 deletions db/fixtures/development/07_milestones.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
ActiveRecord::Base.observers.disable(:milestone_observer)

Milestone.seed(:id, [
{ id: 1, project_id: 1, title: 'v' + Faker::Address.zip_code },
{ id: 2, project_id: 1, title: 'v' + Faker::Address.zip_code },
Expand All @@ -18,5 +16,3 @@
ml.set_iid
ml.save
end

ActiveRecord::Base.observers.enable(:milestone_observer)
9 changes: 7 additions & 2 deletions doc/release/monthly.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ Consider naming the issue "Release x.x.x.rc1" to make it easier for later search
1. Check the [Git version](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/tasks/gitlab/check.rake#L794)
1. There might be other changes. Ask around.

### **3. Create an update guide**
### **3. Create an update guides**

It's best to copy paste the previous guide and make changes where necessary. The typical steps are listed below with any points you should specifically look at.
1. Create: CE update guide from previous version. Like `from-6-8-to-6.9`
1. Create: CE to EE update guide in EE repository for latest version.
1. Update: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/6.0-to-6.x.md to latest version.

It's best to copy paste the previous guide and make changes where necessary.
The typical steps are listed below with any points you should specifically look at.

#### 0. Any major changes?

Expand Down
20 changes: 9 additions & 11 deletions doc/update/6.0-to-6.8.md → doc/update/6.0-to-7.0.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# From 6.0 to 6.8

**In 6.1 we remove a lot of deprecated code.**

**You should update to 6.0 before installing 6.1 or higher so all the necessary conversions are run.**
# From 6.0 to 7.0

## Deprecations

The 'Wall' feature has been removed in GitLab 7.0. Existing wall comments will remain stored in the database after the upgrade.

## Global issue numbers

As of 6.1 issue numbers are project specific. This means all issues are renumbered and get a new number in their URL. If you use an old issue number URL and the issue number does not exist yet you are redirected to the new one. This conversion does not trigger if the old number already exists for this project, this is unlikely but will happen with old issues and large projects.
Expand Down Expand Up @@ -34,15 +32,15 @@ sudo -u git -H git fetch --all
For GitLab Community Edition:

```bash
sudo -u git -H git checkout 6-8-stable
sudo -u git -H git checkout 7-0-stable
```

OR

For GitLab Enterprise Edition:

```bash
sudo -u git -H git checkout 6-8-stable-ee
sudo -u git -H git checkout 7-0-stable-ee
```


Expand Down Expand Up @@ -91,12 +89,12 @@ sudo chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites
TIP: to see what changed in gitlab.yml.example in this release use next command:

```
git diff 6-0-stable:config/gitlab.yml.example 6-8-stable:config/gitlab.yml.example
git diff 6-0-stable:config/gitlab.yml.example 7-0-stable:config/gitlab.yml.example
```

* Make `/home/git/gitlab/config/gitlab.yml` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-8-stable/config/gitlab.yml.example but with your settings.
* Make `/home/git/gitlab/config/unicorn.rb` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-8-stable/config/unicorn.rb.example but with your settings.
* Make `/etc/nginx/sites-available/nginx` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-8-stable/lib/support/nginx/gitlab but with your settings.
* Make `/home/git/gitlab/config/gitlab.yml` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-0-stable/config/gitlab.yml.example but with your settings.
* Make `/home/git/gitlab/config/unicorn.rb` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-0-stable/config/unicorn.rb.example but with your settings.
* Make `/etc/nginx/sites-available/nginx` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-0-stable/lib/support/nginx/gitlab but with your settings.
* Copy rack attack middleware config

```bash
Expand Down
6 changes: 6 additions & 0 deletions features/admin/projects.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ Feature: Admin Projects
When I visit admin projects page
And I click on first project
Then I should see project details

Scenario: Transfer project
Given group 'Web'
And I visit admin project page
When I transfer project to group 'Web'
Then I should see project transfered
26 changes: 26 additions & 0 deletions features/steps/admin/projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,30 @@ class AdminProjects < Spinach::FeatureSteps
page.should have_content(project.name_with_namespace)
page.should have_content(project.creator.name)
end

step 'I visit admin project page' do
visit admin_project_path(project)
end

step 'I transfer project to group \'Web\'' do
find(:xpath, "//input[@id='namespace_id']").set group.id
click_button 'Transfer'
end

step 'group \'Web\'' do
create(:group, name: 'Web')
end

step 'I should see project transfered' do
page.should have_content 'Web / ' + project.name
page.should have_content 'Namespace: Web'
end

def project
@project ||= Project.first
end

def group
Group.find_by(name: 'Web')
end
end
72 changes: 51 additions & 21 deletions spec/models/project_team_spec.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,66 @@
require "spec_helper"

describe ProjectTeam do
let(:group) { create(:group) }
let(:project) { create(:empty_project, group: group) }

let(:master) { create(:user) }
let(:reporter) { create(:user) }
let(:guest) { create(:user) }
let(:nonmember) { create(:user) }

before do
group.add_user(master, Gitlab::Access::MASTER)
group.add_user(reporter, Gitlab::Access::REPORTER)
group.add_user(guest, Gitlab::Access::GUEST)
context 'personal project' do
let(:project) { create(:empty_project) }

# Add group guest as master to this project
# to test project access priority over group members
project.team << [guest, :master]
end
before do
project.team << [master, :master]
project.team << [reporter, :reporter]
project.team << [guest, :guest]
end

describe 'members collection' do
it { project.team.masters.should include(master) }
it { project.team.masters.should include(guest) }
it { project.team.masters.should_not include(reporter) }
it { project.team.masters.should_not include(nonmember) }
describe 'members collection' do
it { project.team.masters.should include(master) }
it { project.team.masters.should_not include(guest) }
it { project.team.masters.should_not include(reporter) }
it { project.team.masters.should_not include(nonmember) }
end

describe 'access methods' do
it { project.team.master?(master).should be_true }
it { project.team.master?(guest).should be_false }
it { project.team.master?(reporter).should be_false }
it { project.team.master?(nonmember).should be_false }
end
end

describe 'access methods' do
it { project.team.master?(master).should be_true }
it { project.team.master?(guest).should be_true }
it { project.team.master?(reporter).should be_false }
it { project.team.master?(nonmember).should be_false }
context 'group project' do
let(:group) { create(:group) }
let(:project) { create(:empty_project, group: group) }

before do
group.add_user(master, Gitlab::Access::MASTER)
group.add_user(reporter, Gitlab::Access::REPORTER)
group.add_user(guest, Gitlab::Access::GUEST)

# If user is a group and a project member - GitLab uses highest permission
# So we add group guest as master and add group master as guest
# to this project to test highest access
project.team << [guest, :master]
project.team << [master, :guest]
end

describe 'members collection' do
it { project.team.reporters.should include(reporter) }
it { project.team.masters.should include(master) }
it { project.team.masters.should include(guest) }
it { project.team.masters.should_not include(reporter) }
it { project.team.masters.should_not include(nonmember) }
end

describe 'access methods' do
it { project.team.reporter?(reporter).should be_true }
it { project.team.master?(master).should be_true }
it { project.team.master?(guest).should be_true }
it { project.team.master?(reporter).should be_false }
it { project.team.master?(nonmember).should be_false }
end
end
end

0 comments on commit 621787d

Please sign in to comment.