diff --git a/CHANGELOG b/CHANGELOG index 8ebd4addcbb..a8403f048b4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ v 7.3.0 - Store session Redis keys in 'session:gitlab:' namespace - Deprecate LDAP account takeover based on partial LDAP email / GitLab username match - Keyboard shortcuts for productivity (Robert Schilling) + - API: filter issues by state (Julien Bianchi) v 7.2.0 - Explore page diff --git a/doc/api/issues.md b/doc/api/issues.md index a4b3b3e9918..c12d4528546 100644 --- a/doc/api/issues.md +++ b/doc/api/issues.md @@ -7,8 +7,14 @@ Get all issues created by authenticated user. This function takes pagination par ``` GET /issues +GET /issues?state=opened +GET /issues?state=closed ``` +Parameters: + +- `state` (optional) - Return `all` issues or just those that are `opened` or `closed` + ```json [ { @@ -80,11 +86,14 @@ to return the list of project issues. ``` GET /projects/:id/issues +GET /projects/:id/issues?state=opened +GET /projects/:id/issues?state=closed ``` Parameters: - `id` (required) - The ID of a project +- `state` (optional) - Return `all` issues or just those that are `opened` or `closed` ## Single issue diff --git a/doc/install/structure.md b/doc/install/structure.md index 67ca1895374..5c03f073c18 100644 --- a/doc/install/structure.md +++ b/doc/install/structure.md @@ -13,9 +13,9 @@ This is the directory structure you will end up with following the instructions * `/home/git/.ssh` - contains openssh settings. Specifically the `authorized_keys` file managed by gitlab-shell. * `/home/git/gitlab` - GitLab core software. * `/home/git/gitlab-satellites` - checked out repositories for merge requests and file editing from web UI. This can be treated as a temporary files directory. -* `/home/git/gitlab-shell` - Core add-on component of gitlab. Maintains SSH cloning and other functionality. +* `/home/git/gitlab-shell` - Core add-on component of GitLab. Maintains SSH cloning and other functionality. * `/home/git/repositories` - bare repositories for all projects organized by namespace. This is where the git repositories which are pushed/pulled are maintained for all projects. **This area is critical data for projects. [Keep a backup](../raketasks/backup_restore.md)** -*Note: the default locations for gitlab-satellites and repositories can be configured in `config/gitlab.yml` of gitlab and `config.yml` of gitlab-shell.* +*Note: the default locations for gitlab-satellites and repositories can be configured in `config/gitlab.yml` of GitLab and `config.yml` of gitlab-shell.* To see a more in-depth overview see the [GitLab architecture doc](../development/architecture.md). diff --git a/doc/update/6.0-to-6.1.md b/doc/update/6.0-to-6.1.md index b8df16bfd97..9d67a3bcb96 100644 --- a/doc/update/6.0-to-6.1.md +++ b/doc/update/6.0-to-6.1.md @@ -73,7 +73,6 @@ sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production ```bash sudo rm /etc/init.d/gitlab sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab -sudo chmod +x /etc/init.d/gitlab ``` ## 7. Start application diff --git a/doc/update/6.0-to-7.2.md b/doc/update/6.0-to-7.2.md index 51e260b9e62..770519a46e0 100644 --- a/doc/update/6.0-to-7.2.md +++ b/doc/update/6.0-to-7.2.md @@ -108,7 +108,6 @@ sudo -u git -H bundle install --without development test postgres --deployment # PostgreSQL installations (note: the line below states '--without ... mysql') sudo -u git -H bundle install --without development test mysql --deployment - # Run database migrations sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production @@ -120,6 +119,9 @@ sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS # Close access to gitlab-satellites for others sudo chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites + +# Update init.d script +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab ``` ## 7. Update config files @@ -146,18 +148,12 @@ sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab ``` -## 8. Update Init script - -```bash -sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab -``` - -## 9. Start application +## 8. Start application sudo service gitlab start sudo service nginx restart -## 10. Check application status +## 9. Check application status Check if GitLab and its environment are configured correctly: @@ -170,7 +166,7 @@ To make sure you didn't miss anything run a more thorough check with: If all items are green, then congratulations upgrade complete! -## 11. Update OmniAuth configuration +## 10. Update OmniAuth configuration When using Google omniauth login, changes of the Google account required. Ensure that `Contacts API` and the `Google+ API` are enabled in the [Google Developers Console](https://console.developers.google.com/). diff --git a/doc/update/6.1-to-6.2.md b/doc/update/6.1-to-6.2.md index f189899f57b..efa6e43124c 100644 --- a/doc/update/6.1-to-6.2.md +++ b/doc/update/6.1-to-6.2.md @@ -88,7 +88,6 @@ sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab ```bash sudo rm /etc/init.d/gitlab sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab -sudo chmod +x /etc/init.d/gitlab ``` ## 8. Start application diff --git a/doc/update/6.2-to-6.3.md b/doc/update/6.2-to-6.3.md index aa6ef56990b..e9b3bdd2f54 100644 --- a/doc/update/6.2-to-6.3.md +++ b/doc/update/6.2-to-6.3.md @@ -74,7 +74,6 @@ sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers ```bash sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab -sudo chmod +x /etc/init.d/gitlab ``` ## 7. Start application diff --git a/doc/update/6.7-to-6.8.md b/doc/update/6.7-to-6.8.md index b5b47f8930e..16f3439c998 100644 --- a/doc/update/6.7-to-6.8.md +++ b/doc/update/6.7-to-6.8.md @@ -62,7 +62,6 @@ sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS # Update init.d script sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab -sudo chmod +x /etc/init.d/gitlab # Close access to gitlab-satellites for others sudo chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites diff --git a/doc/update/6.9-to-7.0.md b/doc/update/6.9-to-7.0.md index f1d3d9c7b2d..bbb3b2617a7 100644 --- a/doc/update/6.9-to-7.0.md +++ b/doc/update/6.9-to-7.0.md @@ -93,7 +93,6 @@ sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS # Update init.d script sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab -sudo chmod +x /etc/init.d/gitlab ``` ### 6. Update config files diff --git a/doc/update/7.0-to-7.1.md b/doc/update/7.0-to-7.1.md index 166ff0ea136..82bb5708734 100644 --- a/doc/update/7.0-to-7.1.md +++ b/doc/update/7.0-to-7.1.md @@ -93,7 +93,6 @@ sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS # Update init.d script sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab -sudo chmod +x /etc/init.d/gitlab ``` ### 6. Update config files diff --git a/doc/update/7.1-to-7.2.md b/doc/update/7.1-to-7.2.md index 04b9ce76a14..b06f62aeb03 100644 --- a/doc/update/7.1-to-7.2.md +++ b/doc/update/7.1-to-7.2.md @@ -77,7 +77,6 @@ sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS # Update init.d script sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab -sudo chmod +x /etc/init.d/gitlab ``` ### 6. Update config files diff --git a/lib/api/issues.rb b/lib/api/issues.rb index eb6a74cd2bc..299fd7e2399 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -3,13 +3,28 @@ module API class Issues < Grape::API before { authenticate! } + helpers do + def filter_issues_state(issues, state = nil) + case state + when 'opened' then issues.opened + when 'closed' then issues.closed + else issues + end + end + end + resource :issues do # Get currently authenticated user's issues # - # Example Request: + # Parameters: + # state (optional) - Return "opened" or "closed" issues + # + # Example Requests: # GET /issues + # GET /issues?state=opened + # GET /issues?state=closed get do - present paginate(current_user.issues), with: Entities::Issue + present paginate(filter_issues_state(current_user.issues, params['state'])), with: Entities::Issue end end @@ -18,10 +33,14 @@ module API # # Parameters: # id (required) - The ID of a project - # Example Request: + # state (optional) - Return "opened" or "closed" issues + # + # Example Requests: # GET /projects/:id/issues + # GET /projects/:id/issues?state=opened + # GET /projects/:id/issues?state=closed get ":id/issues" do - present paginate(user_project.issues), with: Entities::Issue + present paginate(filter_issues_state(user_project.issues, params['state'])), with: Entities::Issue end # Get a single project issue diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 08dc94ebdf3..f70b56b194f 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -4,6 +4,7 @@ describe API::API, api: true do include ApiHelpers let(:user) { create(:user) } let!(:project) { create(:project, namespace: user.namespace ) } + let!(:closed_issue) { create(:closed_issue, author: user, assignee: user, project: project, state: :closed) } let!(:issue) { create(:issue, author: user, assignee: user, project: project) } let!(:label) do create(:label, title: 'label', color: '#FFAABB', project: project) @@ -32,6 +33,31 @@ describe API::API, api: true do response.headers['Link'].should == '; rel="first", ; rel="last"' end + + it 'should return an array of closed issues' do + get api('/issues?state=closed', user) + response.status.should == 200 + json_response.should be_an Array + json_response.length.should == 1 + json_response.first['id'].should == closed_issue.id + end + + it 'should return an array of opened issues' do + get api('/issues?state=opened', user) + response.status.should == 200 + json_response.should be_an Array + json_response.length.should == 1 + json_response.first['id'].should == issue.id + end + + it 'should return an array of all issues' do + get api('/issues?state=all', user) + response.status.should == 200 + json_response.should be_an Array + json_response.length.should == 2 + json_response.first['id'].should == issue.id + json_response.second['id'].should == closed_issue.id + end end end