Skip to content

Commit

Permalink
fix error preventing activity log diff
Browse files Browse the repository at this point in the history
  • Loading branch information
crowesn committed Dec 5, 2023
1 parent dac33e7 commit e753389
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
9 changes: 5 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ GEM
matrix (0.4.2)
method_source (1.0.0)
mini_mime (1.1.5)
minitest (5.19.0)
minitest (5.20.0)
msgpack (1.6.0)
mysql2 (0.5.5)
net-imap (0.3.7)
Expand All @@ -203,8 +203,8 @@ GEM
racc (~> 1.4)
orm_adapter (0.5.0)
pagy (6.0.1)
paper_trail (14.0.0)
activerecord (>= 6.0)
paper_trail (15.1.0)
activerecord (>= 6.1)
request_store (~> 1.4)
parallel (1.22.1)
parser (3.2.0.0)
Expand Down Expand Up @@ -379,10 +379,11 @@ GEM
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.11)
zeitwerk (2.6.12)

PLATFORMS
x86_64-darwin-21
x86_64-darwin-22
x86_64-linux

DEPENDENCIES
Expand Down
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ class Application < Rails::Application
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
config.active_job.queue_adapter = :inline
config.active_record.yaml_column_permitted_classes = [ActiveSupport::TimeWithZone, Time, ActiveSupport::TimeZone]
end
end
8 changes: 8 additions & 0 deletions spec/controllers/activity_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ def sign_in_user(user)
end

describe 'GET #show' do
let(:conservation_record) { create(:conservation_record) }

it 'returns a success response' do
version = PaperTrail::Version.create! valid_attributes
get :show, params: { id: version.to_param }
expect(response).to be_successful
end

it 'returns change details', versioning: true do
conservation_record.update(title: 'The Oddysee')
changes = conservation_record.versions.last.changeset.reject { |k, _v| (k.to_sym == :updated_at) }
expect(changes).to(eq('title' => ['The Illiad', 'The Oddysee']))
end
end
end
3 changes: 1 addition & 2 deletions spec/features/admin_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'rails_helper'

RSpec.describe 'Admin User Tests', type: :feature do
RSpec.describe 'Admin User Tests', type: :feature, versioning: true do
let!(:staff_code) { create(:staff_code, code: 'test', points: 10) }
let(:user) { create(:user, role: 'admin') }
let(:conservation_record) { create(:conservation_record, title: 'Farewell to Arms', department: 2) }
Expand Down Expand Up @@ -77,7 +77,6 @@
select('Admin', from: 'Role')
click_on 'Update User'
expect(page).to have_content('Haritha Vytla')

# View Activity

visit conservation_records_path
Expand Down
16 changes: 14 additions & 2 deletions spec/features/end_to_end_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
end
end

RSpec.describe 'Standard User Tests', type: :feature do
RSpec.describe 'Standard User Tests', type: :feature, versioning: true do
let(:user) { create(:user, role: 'standard') }
let!(:conservation_record) { create(:conservation_record, title: 'Farewell to Arms') }
let!(:staff_code) { create(:staff_code, code: 'test', points: 10) }
Expand Down Expand Up @@ -199,7 +199,7 @@
end
end

RSpec.describe 'Admin User Tests', type: :feature do
RSpec.describe 'Admin User Tests', type: :feature, versioning: true do
let(:user) { create(:user, role: 'admin') }
let(:conservation_record) { create(:conservation_record, title: 'Farewell to Arms') }
let(:vocabulary) { create(:controlled_vocabulary) }
Expand Down Expand Up @@ -402,5 +402,17 @@
expect(page).to have_content('Haritha Vytla deleted the in house repair record')
expect(page).to_not have_content('Haritha Vytla created the treatment report')
expect(page).to have_content('Haritha Vytla updated the treatment report')

# Check that details page shows diff data
visit conservation_records_path
click_link(conservation_record.title, match: :prefer_exact)
fill_in 'treatment_report_description_binding', with: 'Half leather tightjoint, tight back binding'
click_button('Save Treatment Report')
expect(page).to have_content('Treatment Record updated successfully!')
visit activity_index_path
expect(page).to have_content('Haritha Vytla updated the treatment report')
first('tr').click_link('Details')
expect(page).to have_content('Full leather tightjoint, tight back binding')
expect(page).to have_content('Half leather tightjoint, tight back binding')
end
end
1 change: 1 addition & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
abort('The Rails environment is running in production mode!') if Rails.env.production?
require 'factory_bot'
require 'rspec/rails'
require 'paper_trail/frameworks/rspec'
# Add additional requires below this line. Rails is not loaded until this point!

# Requires supporting ruby files with custom matchers and macros, etc, in
Expand Down

0 comments on commit e753389

Please # to comment.