diff options
author | Felipe Artur <felipefac@gmail.com> | 2016-12-08 23:32:08 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2016-12-12 20:31:14 +0300 |
commit | ac00009fccec66a768ae9dffff4b453ad2a6b13f (patch) | |
tree | d3fb2ea99aca3f0f77e5857787cc16e43c3e80a9 /spec | |
parent | 10d4b20ad18b735e45da492a1af30b3650df705e (diff) |
Allow to delete tag release note
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/releases_controller_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/controllers/projects/releases_controller_spec.rb b/spec/controllers/projects/releases_controller_spec.rb new file mode 100644 index 00000000000..9fd5c3b85f6 --- /dev/null +++ b/spec/controllers/projects/releases_controller_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper' + +describe Projects::ReleasesController do + let!(:project) { create(:project) } + let!(:user) { create(:user) } + let!(:release) { create(:release, project: project) } + let!(:tag) { release.tag } + + before do + project.team << [user, :developer] + sign_in(user) + end + + describe 'GET #edit' do + it 'initializes a new release' do + tag_id = release.tag + project.releases.destroy_all + + get :edit, namespace_id: project.namespace.path, project_id: project.path, tag_id: tag_id + + release = assigns(:release) + expect(release).not_to be_nil + expect(release).not_to be_persisted + end + + it 'retrieves an existing release' do + get :edit, namespace_id: project.namespace.path, project_id: project.path, tag_id: release.tag + + release = assigns(:release) + expect(release).not_to be_nil + expect(release).to be_persisted + end + end + + describe 'PUT #update' do + it 'updates release note description' do + update_release('description updated') + + release = project.releases.find_by_tag(tag) + expect(release.description).to eq("description updated") + end + + it 'deletes release note when description is null' do + expect { update_release('') }.to change(project.releases, :count).by(-1) + end + end + + def update_release(description) + put :update, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + tag_id: release.tag, + release: { description: description } + end +end |