Skip to content

Commit

Permalink
Use fork of Audited gem
Browse files Browse the repository at this point in the history
We had two bugs with the audited gem, and I've opened PRs for both of them:

collectiveidea/audited#522
collectiveidea/audited#523

In the meantime, while we're waiting for them to hopefully be approved and merged, I have created my own fork with a branch that has both of those changes in.

This means that we no longer need the monkey pathes in the dwelling and development models. Also update the specs to reflect the new, fixed error messages.
  • Loading branch information
james committed Nov 5, 2019
1 parent fb9c203 commit 334262d
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ gem 'devise'

gem 'aasm'

gem 'audited'
gem 'audited', git: '[email protected]:james/audited.git', branch: 'southwark'

# Used by seeds.rb
gem 'faker', git: 'https://github.com/faker-ruby/faker.git', branch: 'master'
Expand Down
12 changes: 9 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
GIT
remote: [email protected]:james/audited.git
revision: dc144779bff52561f18968f1ca2a9d3eff20d6c0
branch: southwark
specs:
audited (4.9.0)
activerecord (>= 4.2, < 6.1)

GIT
remote: https://github.com/faker-ruby/faker.git
revision: 4ba30fb28072e942420ebf2d58da73969ae6159b
Expand Down Expand Up @@ -69,8 +77,6 @@ GEM
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.0)
audited (4.9.0)
activerecord (>= 4.2, < 6.1)
bcrypt (3.1.13)
bindex (0.8.1)
bootsnap (1.4.5)
Expand Down Expand Up @@ -291,7 +297,7 @@ PLATFORMS

DEPENDENCIES
aasm
audited
audited!
bootsnap (>= 1.4.2)
byebug
capybara (>= 2.15)
Expand Down
9 changes: 0 additions & 9 deletions app/models/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,4 @@ def completion_response_filled?
def set_developer_access_key
self.developer_access_key = SecureRandom.urlsafe_base64(20)
end

def comment_required_state?
# Monkey patch explanation:
# The Audited gem doesn't create a changelog if there are no audited_changes
# eg in the situation where we're only changing `state`, and state is ignored by
# audited. So in this situation, we shouldn't require a comment either.
# TODO: Make this a PR on the audited gem itself
super && audited_changes.present?
end
end
12 changes: 0 additions & 12 deletions app/models/dwelling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,4 @@ class Dwelling < ApplicationRecord
validates :bedrooms, presence: true

delegate :audit_changes?, to: :development

private

def comment_required_state?
# Monkey patch explanation:
# The Audited gem doesn't create a changelog if there are no audited_changes
# eg in the situation where we're only changing `address`, and address is
# ignored by audited. So in this situation, we shouldn't require a comment
# either.
# TODO: Make this a PR on the audited gem itself
super && audited_changes.present?
end
end
2 changes: 1 addition & 1 deletion spec/features/creating_dwellings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@
click_link 'Add a new dwelling'
fill_in 'Changelog', with: ''
click_button 'Add dwelling'
expect(page).to have_content("Audit comment Comment can't be blank")
expect(page).to have_content("Audit comment can't be blank")
end
end
2 changes: 1 addition & 1 deletion spec/features/deleting_dwellings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@
click_link 'Delete dwelling'
fill_in 'Deletion reason', with: ''
click_button 'Delete dwelling'
expect(page).to have_content("Audit comment Comment can't be blank")
expect(page).to have_content("Audit comment can't be blank")
end
end
2 changes: 1 addition & 1 deletion spec/features/editing_developments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
fill_in 'Proposal', with: 'Build a building edited'
fill_in 'Changelog', with: ''
click_button 'Save and continue'
expect(page).to have_content("Audit comment Comment can't be blank")
expect(page).to have_content("Audit comment can't be blank")
end

scenario 'unable to view if not logged in' do
Expand Down
2 changes: 1 addition & 1 deletion spec/features/editing_dwellings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@
select 'social', from: 'Tenure'
fill_in 'Changelog', with: ''
click_button 'Save dwelling'
expect(page).to have_content("Audit comment Comment can't be blank")
expect(page).to have_content("Audit comment can't be blank")
end
end

0 comments on commit 334262d

Please sign in to comment.