diff --git a/app/helpers/tabs/observations_helper.rb b/app/helpers/tabs/observations_helper.rb index 441dd9b574..c04baecd05 100644 --- a/app/helpers/tabs/observations_helper.rb +++ b/app/helpers/tabs/observations_helper.rb @@ -145,14 +145,20 @@ def observations_at_where_tabs(query) # these are from the observations form def define_location_tab(query) [:list_observations_location_define.l, - add_query_param(new_location_path(where: query.params[:user_where])), + add_query_param(new_location_path(where: where_param(query.params))), { class: tab_id(__method__.to_s) }] end + # Hack to use the :locations param if it's present and the :user_where + # param is missing. + def where_param(query_params) + query_params[:user_where] || params[:where] + end + def assign_undefined_location_tab(query) [:list_observations_location_merge.l, add_query_param(matching_locations_for_observations_path( - where: query.params[:user_where] + where: where_param(query.params) )), { class: tab_id(__method__.to_s) }] end diff --git a/app/models/field_slip_job_tracker.rb b/app/models/field_slip_job_tracker.rb index c128b80db7..7b8c5f084e 100644 --- a/app/models/field_slip_job_tracker.rb +++ b/app/models/field_slip_job_tracker.rb @@ -5,12 +5,7 @@ class FieldSlipJobTracker < AbstractModel SUBDIR = "shared" PDF_DIR = PUBLIC_DIR + SUBDIR - enum status: - { - Starting: 1, - Processing: 2, - Done: 3 - } + enum :status, { Starting: 1, Processing: 2, Done: 3 } belongs_to :user diff --git a/app/models/location_description.rb b/app/models/location_description.rb index 614724c8f9..e6f14cd9b2 100644 --- a/app/models/location_description.rb +++ b/app/models/location_description.rb @@ -50,16 +50,10 @@ class LocationDescription < Description require "acts_as_versioned" - # enum definitions for use by simple_enum gem # Do not change the integer associated with a value - enum source_type: - { - public: 1, - foreign: 2, - project: 3, - source: 4, - user: 5 - }, _suffix: :source + enum :source_type, + { public: 1, foreign: 2, project: 3, source: 4, user: 5 }, + suffix: :source, instance_methods: false belongs_to :license belongs_to :location diff --git a/app/models/name.rb b/app/models/name.rb index e3b8c3ea84..473758646d 100644 --- a/app/models/name.rb +++ b/app/models/name.rb @@ -348,7 +348,6 @@ class Name < AbstractModel extend Parse extend Create - # enum definitions for use by simple_enum gem # Do not change the integer associated with a value enum :rank, { Form: 1, diff --git a/app/models/name_description.rb b/app/models/name_description.rb index e7dd971347..93fc93046b 100644 --- a/app/models/name_description.rb +++ b/app/models/name_description.rb @@ -65,23 +65,12 @@ class NameDescription < Description require "acts_as_versioned" - # enum definitions for use by simple_enum gem # Do not change the integer associated with a value - enum review_status: - { - unreviewed: 1, - unvetted: 2, - vetted: 3, - inaccurate: 4 - } - enum source_type: - { - public: 1, - foreign: 2, - project: 3, - source: 4, - user: 5 - }, _suffix: :source + enum :review_status, { unreviewed: 1, unvetted: 2, vetted: 3, inaccurate: 4 } + + enum :source_type, { public: 1, foreign: 2, project: 3, source: 4, user: 5 }, + suffix: :source, instance_methods: false + belongs_to :license belongs_to :name belongs_to :project diff --git a/app/models/project_member.rb b/app/models/project_member.rb index f65494a49b..3b7d69fd01 100644 --- a/app/models/project_member.rb +++ b/app/models/project_member.rb @@ -1,12 +1,7 @@ # frozen_string_literal: true class ProjectMember < ApplicationRecord - enum trust_level: - { - no_trust: 1, - hidden_gps: 2, - editing: 3 - } + enum :trust_level, { no_trust: 1, hidden_gps: 2, editing: 3 } belongs_to :project belongs_to :user diff --git a/app/models/user.rb b/app/models/user.rb index 9d65b30fe9..0d23a99ed8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -199,62 +199,26 @@ class User < AbstractModel # rubocop:disable Metrics/ClassLength require "digest/sha1" - # enum definitions for use by simple_enum gem # Do not change the integer associated with a value - # first value is the default - enum thumbnail_size: - { - thumbnail: 1, - small: 2 - }, - _prefix: :thumb_size, - _default: "thumbnail" - - enum image_size: - { - thumbnail: 1, - small: 2, - medium: 3, - large: 4, - huge: 5, - full_size: 6 - }, - _prefix: true, - _default: "medium" - - enum votes_anonymous: - { - no: 1, - yes: 2, - old: 3 - }, - _prefix: :votes_anon, - _default: "no" - - enum location_format: - { - postal: 1, - scientific: 2 - }, - _prefix: true, - _default: "postal" - - enum hide_authors: - { - none: 1, - above_species: 2 - }, - _prefix: true, - _default: "none" - - enum keep_filenames: - { - toss: 1, - keep_but_hide: 2, - keep_and_show: 3 - }, - _suffix: :filenames, - _default: "toss" + # First value is the default + enum :thumbnail_size, { thumbnail: 1, small: 2 }, + prefix: :thumb_size, default: :thumbnail, instance_methods: false + + enum :image_size, + { thumbnail: 1, small: 2, medium: 3, large: 4, huge: 5, full_size: 6 }, + prefix: true, default: :medium, instance_methods: false + + enum :votes_anonymous, { no: 1, yes: 2, old: 3 }, + prefix: :votes_anon, default: :no, instance_methods: false + + enum :location_format, { postal: 1, scientific: 2 }, + prefix: true, default: :postal, instance_methods: false + + enum :hide_authors, { none: 1, above_species: 2 }, + prefix: true, default: :none, instance_methods: false + + enum :keep_filenames, { toss: 1, keep_but_hide: 2, keep_and_show: 3 }, + suffix: :filenames, default: :toss, instance_methods: false has_one :user_stats, dependent: :destroy diff --git a/test/controllers/observations_controller/observations_controller_index_test.rb b/test/controllers/observations_controller/observations_controller_index_test.rb index 079757f6fa..909a4c8cf9 100644 --- a/test/controllers/observations_controller/observations_controller_index_test.rb +++ b/test/controllers/observations_controller/observations_controller_index_test.rb @@ -542,6 +542,7 @@ def test_index_where login get(:index, params: { where: location.name }) assert_displayed_title("Observations from #{location.name}") + assert_match(new_location_path(where: location.name), @response.body) end def test_index_where_page2