Skip to content

Commit 4e9024d

Browse files
authored
Merge pull request #531 from wri/develop
Release
2 parents d3f4dbb + 76ec065 commit 4e9024d

File tree

16 files changed

+86
-36
lines changed

16 files changed

+86
-36
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ spec/.DS_Store
4343
/db/*.sqlite3
4444
/db/*.sqlite3-journal
4545

46-
# Ignore ERD images
47-
erd.png
48-
4946
# Ignore the document files to import
5047
/db/files/operator_document_files
5148

Gemfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,8 @@ gem "countries", require: false # for update translations job, so require only t
110110

111111
group :development, :test do
112112
gem "debug", platforms: %i[mri mingw x64_mingw]
113-
gem "factory_bot_rails"
114-
gem "faker"
115-
gem "parallel_tests"
116-
gem "rails-erd"
117-
gem "rubocop-rails"
118-
gem "standard"
119-
gem "webmock"
113+
gem "rubocop-rails", require: false
114+
gem "standard", require: false
120115
end
121116

122117
group :development do
@@ -144,12 +139,17 @@ group :test do
144139
gem "capybara"
145140
gem "cuprite"
146141
gem "database_cleaner"
142+
gem "factory_bot_rails"
143+
gem "faker"
144+
gem "parallel_tests"
147145
gem "rspec-collection_matchers"
148146
gem "rspec-rails"
149147
gem "rspec-request_snapshot", github: "tsubik/rspec-request_snapshot", branch: "fix/ignore-order"
150148
gem "shoulda-matchers", "~> 4.0.1"
151149
gem "simplecov"
150+
gem "spring-commands-rspec"
152151
gem "super_diff"
152+
gem "webmock"
153153
end
154154

155155
# Server

Gemfile.lock

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ GEM
231231
chartkick (5.1.5)
232232
childprocess (5.1.0)
233233
logger (~> 1.5)
234-
choice (0.2.0)
235234
chronic (0.10.2)
236235
concurrent-ruby (1.3.5)
237236
connection_pool (2.5.3)
@@ -559,11 +558,6 @@ GEM
559558
activesupport (>= 5.0.0)
560559
minitest
561560
nokogiri (>= 1.6)
562-
rails-erd (1.7.2)
563-
activerecord (>= 4.2)
564-
activesupport (>= 4.2)
565-
choice (~> 0.2.0)
566-
ruby-graphviz (~> 1.2)
567561
rails-html-sanitizer (1.6.2)
568562
loofah (~> 2.21)
569563
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
@@ -674,8 +668,6 @@ GEM
674668
rack (>= 1.1)
675669
rubocop (>= 1.75.0, < 2.0)
676670
rubocop-ast (>= 1.38.0, < 2.0)
677-
ruby-graphviz (1.2.5)
678-
rexml
679671
ruby-progressbar (1.13.0)
680672
ruby-vips (2.2.3)
681673
ffi (~> 1.12)
@@ -724,6 +716,9 @@ GEM
724716
simplecov_json_formatter (~> 0.1)
725717
simplecov-html (0.13.1)
726718
simplecov_json_formatter (0.1.4)
719+
spring (4.3.0)
720+
spring-commands-rspec (1.0.4)
721+
spring (>= 0.9.1)
727722
sprockets (4.2.2)
728723
concurrent-ruby (~> 1.0)
729724
logger
@@ -864,7 +859,6 @@ DEPENDENCIES
864859
rack-cors
865860
rack-mini-profiler (~> 2.0)
866861
rails (~> 7.2.2)
867-
rails-erd
868862
redis-rails
869863
rgeo
870864
rgeo-geojson
@@ -884,6 +878,7 @@ DEPENDENCIES
884878
shoulda-matchers (~> 4.0.1)
885879
sidekiq
886880
simplecov
881+
spring-commands-rspec
887882
sprockets-rails
888883
standard
889884
super_diff

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,20 @@ bundle exec rake parallel:drop
171171

172172
For more information about parallel tests check [parallel_tests gem.](https://github.com/grosser/parallel_tests)
173173

174+
### Running single test faster with spring ###
175+
176+
You can use spring to run single tests faster. There is bin/rspec stub that will run the tests with spring. You can use it like this:
177+
178+
```ruby
179+
bin/rspec spec/models/user_spec.rb
180+
```
181+
182+
or just prepend spring to the command:
183+
184+
```ruby
185+
bundle exec spring rspec spec/models/user_spec.rb
186+
```
187+
174188
## DOCUMENTATION ##
175189

176190
### API ###

app/admin/observation_report.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def apply_filtering(chain)
137137
f.input :user
138138
f.input :title
139139
f.input :publication_date, as: :date_time_picker, picker_options: {timepicker: false, format: "Y-m-d"}
140-
f.input :attachment, as: :file, hint: f.object&.attachment&.file&.filename
140+
f.input :attachment, as: :file, hint: f.object&.attachment&.file&.filename, input_html: {accept: "application/pdf"}
141141
f.input :observers
142142
end
143143

app/resources/concerns/operator_documentable.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ def status
4141
return @model.status if can_see_document?
4242
return @model.status if document_public? && %w[doc_not_provided doc_valid doc_expired doc_not_required].include?(@model.status)
4343

44-
:doc_not_provided
44+
"doc_not_provided"
4545
end
4646

4747
def attachment
48-
return @model&.document_file&.attachment if document_visible?
48+
return {url: nil} if %w[doc_not_provided doc_not_required].include?(status)
4949

50-
{url: nil}
50+
@model&.document_file&.attachment
5151
end
5252

5353
def attachment=(attachment)

app/uploaders/observation_report_uploader.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class ObservationReportUploader < ApplicationUploader
44
def extension_allowlist
5-
%w[pdf doc docx txt csv xml jpg jpeg png exif tiff bmp]
5+
%w[pdf]
66
end
77

88
def filename

bin/rspec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env ruby
2+
load File.expand_path("spring", __dir__)
3+
require 'bundler/setup'
4+
load Gem.bin_path('rspec-core', 'rspec')

bin/spring

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env ruby
2+
3+
# This file loads Spring without loading other gems in the Gemfile in order to be fast.
4+
# It gets overwritten when you run the `spring binstub` command.
5+
6+
if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"])
7+
require "bundler"
8+
9+
Bundler.locked_gems.specs.find { |spec| spec.name == "spring" }&.tap do |spring|
10+
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
11+
gem "spring", spring.version
12+
require "spring/binstub"
13+
end
14+
end

config/environments/test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
Rails.application.configure do
1010
# Settings specified here will take precedence over those in config/application.rb.
1111

12-
# While tests run files are not watched, reloading is not necessary.
13-
config.enable_reloading = false
12+
# While tests run files are not watched, reloading is not necessary. (unless you are using Spring)
13+
config.enable_reloading = ENV["SPRING_SPAWN_ENV"].present?
1414

1515
# Eager loading loads your entire application. When running a single test locally,
1616
# this is usually not necessary, and can slow down your test suite. However, it's

0 commit comments

Comments
 (0)