diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-03 13:27:30 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-03 13:27:30 +0300 |
commit | 738bf2c23891467dbc9c74d08223fd3c4e432ae7 (patch) | |
tree | 46f3aecaa33309822710a3aac2bb211a4855b37b /spec/controllers/projects | |
parent | eb45582f55cae42acc41fa228f4797b4067c01dc (diff) | |
parent | 40cc917a9c07263db062c03f62c8056ed40197bd (diff) |
Merge branch 'master' into feature/gb/manual-actions-protected-branches-permissions
* master: (103 commits)
Include missing project attributes to Import/Export
Create the rest of the wiki docs
Fill in information about creating the wiki Home page
Move wiki doc to its own index page
Create initial file for Wiki documentation
Default to null user when asignee is unselected
Re-enable ref operations with gitaly after not-found fix
#31560 Add repo parameter to gitaly:install and workhorse:install
Remove N+1 queries when checking nodes visible to user
Don't validate reserved words if the format doesn't match
Revert "Shorten and improve some job names"
Remove unused initializer
DRY the `<<: *except-docs` a bit in `.gitlab-ci.yml`
Make the static-analysis job be run for docs branches too
Add download_snippet_path helper
Refresh the markdown cache if it was `nil`
Add some documentation for the new migration helpers
Update comments
Display comments for personal snippets
Update docs on creating a project
...
Diffstat (limited to 'spec/controllers/projects')
-rw-r--r-- | spec/controllers/projects/deployments_controller_spec.rb | 42 | ||||
-rw-r--r-- | spec/controllers/projects/notes_controller_spec.rb | 41 |
2 files changed, 83 insertions, 0 deletions
diff --git a/spec/controllers/projects/deployments_controller_spec.rb b/spec/controllers/projects/deployments_controller_spec.rb new file mode 100644 index 00000000000..89692b601b2 --- /dev/null +++ b/spec/controllers/projects/deployments_controller_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' + +describe Projects::DeploymentsController do + include ApiHelpers + + let(:user) { create(:user) } + let(:project) { create(:empty_project) } + let(:environment) { create(:environment, name: 'production', project: project) } + + before do + project.add_master(user) + + sign_in(user) + end + + describe 'GET #index' do + it 'returns list of deployments from last 8 hours' do + create(:deployment, environment: environment, created_at: 9.hours.ago) + create(:deployment, environment: environment, created_at: 7.hours.ago) + create(:deployment, environment: environment) + + get :index, environment_params(after: 8.hours.ago) + + expect(response).to be_ok + + expect(json_response['deployments'].count).to eq(2) + end + + it 'returns a list with deployments information' do + create(:deployment, environment: environment) + + get :index, environment_params + + expect(response).to be_ok + expect(response).to match_response_schema('deployments') + end + end + + def environment_params(opts = {}) + opts.reverse_merge(namespace_id: project.namespace, project_id: project, environment_id: environment.id) + end +end diff --git a/spec/controllers/projects/notes_controller_spec.rb b/spec/controllers/projects/notes_controller_spec.rb index f140eaef5d5..45f4cf9180d 100644 --- a/spec/controllers/projects/notes_controller_spec.rb +++ b/spec/controllers/projects/notes_controller_spec.rb @@ -167,6 +167,47 @@ describe Projects::NotesController do end end + describe 'DELETE destroy' do + let(:request_params) do + { + namespace_id: project.namespace, + project_id: project, + id: note, + format: :js + } + end + + context 'user is the author of a note' do + before do + sign_in(note.author) + project.team << [note.author, :developer] + end + + it "returns status 200 for html" do + delete :destroy, request_params + + expect(response).to have_http_status(200) + end + + it "deletes the note" do + expect { delete :destroy, request_params }.to change { Note.count }.from(1).to(0) + end + end + + context 'user is not the author of a note' do + before do + sign_in(user) + project.team << [user, :developer] + end + + it "returns status 404" do + delete :destroy, request_params + + expect(response).to have_http_status(404) + end + end + end + describe 'POST toggle_award_emoji' do before do sign_in(user) |