Skip to content

Commit 535ac1c

Browse files
authored
Merge pull request #592 from alphagov/fix-clearing-notes
Fix clearing the petition notes field
2 parents 308ba54 + 8229a6e commit 535ac1c

4 files changed

Lines changed: 17 additions & 22 deletions

File tree

app/models/note.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ class Note < ActiveRecord::Base
22
belongs_to :petition, touch: true
33

44
validates :petition, presence: true
5-
validates :details, presence: true
65
end

features/admin/notes.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,19 @@ Feature: A moderator user updates records notes
3232
Then I should be on the admin petition page for "Solidarity with the Unions"
3333
And I follow "Notes"
3434
Then I should see "I think we can debate this, will check with unions select committee first"
35+
36+
Scenario: Removing notes
37+
Given an open petition exists with action: "Solidarity with the Unions"
38+
When I am on the admin all petitions page
39+
And I follow "Solidarity with the Unions"
40+
And I follow "Notes"
41+
Then I should see a "Notes" textarea field
42+
And the markup should be valid
43+
When I fill in "Notes" with "I think we can debate this, will check with unions select committee first"
44+
And I press "Save"
45+
Then I should be on the admin petition page for "Solidarity with the Unions"
46+
And I follow "Notes"
47+
Then I should see "I think we can debate this, will check with unions select committee first"
48+
When I fill in "Notes" with ""
49+
And I press "Save"
50+
Then I should be on the admin petition page for "Solidarity with the Unions"

spec/controllers/admin/notes_controller_spec.rb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,6 @@ def do_patch(overrides = {})
117117
expect(petition.note.details).to eq notes_attributes[:details]
118118
end
119119
end
120-
121-
describe 'with invalid params' do
122-
it 're-renders the notes/show template' do
123-
do_patch(note: { details: "" })
124-
expect(response).to be_success
125-
expect(response).to render_template('petitions/show')
126-
end
127-
128-
it 'leaves the in-memory instance with errors' do
129-
do_patch(note: { details: "" })
130-
expect(assigns(:note)).to be_present
131-
expect(assigns(:note).errors).not_to be_empty
132-
end
133-
134-
it 'does not stores the supplied notes in the db' do
135-
do_patch(note: { details: "" })
136-
petition.reload
137-
expect(petition.note).to be_nil
138-
end
139-
end
140120
end
141121

142122
describe 'for an open petition' do

spec/models/note_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
subject { FactoryGirl.build(:note) }
1818

1919
it { is_expected.to validate_presence_of(:petition) }
20-
it { is_expected.to validate_presence_of(:details) }
20+
it { is_expected.not_to validate_presence_of(:details) }
2121
end
2222
end

0 commit comments

Comments
 (0)