diff options
author | Rémy Coutable <remy@rymai.me> | 2016-09-30 09:27:28 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-09-30 09:27:28 +0000 |
commit | f9887a10d43fc3b382d1ef270431823d1d4491a6 (patch) | |
tree | e8da6ddacb004cd087a246e2149f57be4bd0ea15 /spec | |
parent | dde96231833e9b4673cd04686953205b2105416d (diff) | |
parent | c81c853a0db25342142021affaa4617af1818add (diff) | |
download | gitlab-ce-f9887a10d43fc3b382d1ef270431823d1d4491a6.tar.gz |
Merge branch '22452-milestone-title-unnecessary-escaping-fix' into 'master'
This MR fixes a bug that unnecessary escapes reserved HTML characters for Milestone's title. See #22452.
## Are there points in the code the reviewer needs to double check?
- Unescaping of sanitized milestone title before it is being stored in the database. See `Milestone#title` and a private method called `Milestone#sanitize_title`
- Sufficient tests were added (Model and API tests were modified/added).
## Why was this MR needed?
To allow reserved HTML characters in a milestone's title, such as "PHP migration 5.6 -> 7.0". The text appears in 'milestones' and in a dropdown during issue creation, issue list, and in another dropdown for issue filter.
Closes #22452
See merge request !6533
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/milestone_spec.rb | 4 | ||||
-rw-r--r-- | spec/requests/api/milestones_spec.rb | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index d64d6cde2b5..33fe22dd98c 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -20,10 +20,10 @@ describe Milestone, models: true do let(:user) { create(:user) } describe "#title" do - let(:milestone) { create(:milestone, title: "<b>test</b>") } + let(:milestone) { create(:milestone, title: "<b>foo & bar -> 2.2</b>") } it "sanitizes title" do - expect(milestone.title).to eq("test") + expect(milestone.title).to eq("foo & bar -> 2.2") end end diff --git a/spec/requests/api/milestones_spec.rb b/spec/requests/api/milestones_spec.rb index b89dac01040..dd192bea432 100644 --- a/spec/requests/api/milestones_spec.rb +++ b/spec/requests/api/milestones_spec.rb @@ -104,6 +104,14 @@ describe API::API, api: true do expect(response).to have_http_status(400) end + + it 'creates a new project with reserved html characters' do + post api("/projects/#{project.id}/milestones", user), title: 'foo & bar 1.1 -> 2.2' + + expect(response).to have_http_status(201) + expect(json_response['title']).to eq('foo & bar 1.1 -> 2.2') + expect(json_response['description']).to be_nil + end end describe 'PUT /projects/:id/milestones/:milestone_id' do |