Skip to content

Commit

Permalink
rubocops
Browse files Browse the repository at this point in the history
  • Loading branch information
nimmolo committed Jan 5, 2024
1 parent 0f07a44 commit 4f49bc3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
8 changes: 4 additions & 4 deletions app/models/observation/naming_consensus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ def owners_vote(naming)

# Get a given User's Vote on a given Naming.
def users_vote(naming, user)
votes.select { |v|
votes.select do |v|
return v if v.user_id == user.id && v.naming_id == naming.id
}
end
nil
end

Expand Down Expand Up @@ -142,9 +142,9 @@ def owners_favorite?(naming)
# votes from the given user (among namings for this observation).
# Note: multiple namings can return true for a given user and observation.
def users_favorite?(naming, user)
votes.any? { |v|
votes.any? do |v|
v.user_id == user.id && v.naming_id == naming.id && v.favorite
}
end
end

# All of observation.user's votes on all Namings for this Observation
Expand Down
16 changes: 1 addition & 15 deletions app/models/species_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,7 @@ class SpeciesList < AbstractModel

scope :show_includes, lambda {
includes(
# :collection_numbers,
{ observations: :namings },
# { external_links: { external_site: { project: :user_group } } },
# { herbarium_records: [{ herbarium: :curators }, :user] },
# { images: [:image_votes, :license, :projects, :user] },
# { interests: :user },
# :location,
# :name,
# { namings: [:name, :user, { votes: [:observation, :user] }] },
# { projects: :admin_group },
# :rss_log,
# :sequences,
# { species_lists: [:projects, :user] },
# :thumb_image,
# :user
{ observations: :namings }
)
}

Expand Down
6 changes: 3 additions & 3 deletions test/models/observation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -701,13 +701,13 @@ def test_vote_favorite
consensus.change_vote(namg1, -0.01, mary)
namings.each(&:reload)
obs.reload
assert_not(consensus.users_favorite?(namg1,mary))
assert_not(consensus.users_favorite?(namg1, mary))
assert(consensus.users_favorite?(namg2, mary))
assert_not(consensus.users_favorite?(namg3, mary))
assert_not(consensus.users_favorite?(namg1,rolf))
assert_not(consensus.users_favorite?(namg1, rolf))
assert_not(consensus.users_favorite?(namg2, rolf))
assert(consensus.users_favorite?(namg3, rolf))
assert_not(consensus.users_favorite?(namg1,dick))
assert_not(consensus.users_favorite?(namg1, dick))
assert_not(consensus.users_favorite?(namg2, dick))
assert_not(consensus.users_favorite?(namg3, dick))
assert_names_equal(@name3, obs.name)
Expand Down

0 comments on commit 4f49bc3

Please sign in to comment.