Skip to content

Fix for AO3-4580 - inviting to hidden/anon collection causes work to become hidden/anon #2468

Merged
merged 4 commits into from Jun 2, 2016

3 participants

@shalott
Organization for Transformative Works member
shalott commented May 28, 2016
@shalott shalott Fix for AO3-4580
Signed-off-by: astolat shalott <[email protected]>
bfbbec1
@houndci-bot houndci-bot commented on an outdated diff May 28, 2016
lib/collectible.rb
def update_anon_unrevealed
if self.respond_to?(:in_anon_collection) && self.respond_to?(:in_unrevealed_collection)
- self.in_anon_collection = !self.collection_items.select {|c| c.anonymous? }.empty?
- self.in_unrevealed_collection = !self.collection_items.select{|c| c.unrevealed? }.empty?
+ self.in_anon_collection = !self.user_approved_collection_items.select {|c| c.anonymous? }.empty?
+ self.in_unrevealed_collection = !self.user_approved_collection_items.select{|c| c.unrevealed? }.empty?
@houndci-bot
houndci-bot added a note May 28, 2016

Redundant self detected.
Space missing to the left of {.
Space between { and | missing.
Pass &:unrevealed? as an argument to select instead of a block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on an outdated diff May 28, 2016
lib/collectible.rb
def update_anon_unrevealed
if self.respond_to?(:in_anon_collection) && self.respond_to?(:in_unrevealed_collection)
- self.in_anon_collection = !self.collection_items.select {|c| c.anonymous? }.empty?
- self.in_unrevealed_collection = !self.collection_items.select{|c| c.unrevealed? }.empty?
+ self.in_anon_collection = !self.user_approved_collection_items.select {|c| c.anonymous? }.empty?
@houndci-bot
houndci-bot added a note May 28, 2016

Redundant self detected.
Space between { and | missing.
Pass &:anonymous? as an argument to select instead of a block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on an outdated diff May 28, 2016
lib/collectible.rb
def set_anon_unrevealed
if self.respond_to?(:in_anon_collection) && self.respond_to?(:in_unrevealed_collection)
- self.in_anon_collection = !self.collections.select {|c| c.anonymous? }.empty?
- self.in_unrevealed_collection = !self.collections.select{|c| c.unrevealed? }.empty?
+ self.in_anon_collection = !self.user_approved_collections.select {|c| c.anonymous? }.empty?
+ self.in_unrevealed_collection = !self.user_approved_collections.select{|c| c.unrevealed? }.empty?
@houndci-bot
houndci-bot added a note May 28, 2016

Redundant self detected.
Space missing to the left of {.
Space between { and | missing.
Pass &:unrevealed? as an argument to select instead of a block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on an outdated diff May 28, 2016
lib/collectible.rb
@@ -16,6 +18,10 @@ def self.included(collectible)
:through => :collection_items,
:source => :collection,
:conditions => ['collection_items.user_approval_status = ? AND collection_items.collection_approval_status = ?', CollectionItem::APPROVED, CollectionItem::APPROVED]
+ has_many :user_approved_collections,
+ :through => :collection_items,
+ :source => :collection,
+ :conditions => ['collection_items.user_approval_status = ?', CollectionItem::APPROVED]
@houndci-bot
houndci-bot added a note May 28, 2016

Use the new Ruby 1.9 hash syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on an outdated diff May 28, 2016
lib/collectible.rb
def set_anon_unrevealed
if self.respond_to?(:in_anon_collection) && self.respond_to?(:in_unrevealed_collection)
- self.in_anon_collection = !self.collections.select {|c| c.anonymous? }.empty?
- self.in_unrevealed_collection = !self.collections.select{|c| c.unrevealed? }.empty?
+ self.in_anon_collection = !self.user_approved_collections.select {|c| c.anonymous? }.empty?
@houndci-bot
houndci-bot added a note May 28, 2016

Redundant self detected.
Space between { and | missing.
Pass &:anonymous? as an argument to select instead of a block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on an outdated diff May 28, 2016
lib/collectible.rb
@@ -16,6 +18,10 @@ def self.included(collectible)
:through => :collection_items,
:source => :collection,
:conditions => ['collection_items.user_approval_status = ? AND collection_items.collection_approval_status = ?', CollectionItem::APPROVED, CollectionItem::APPROVED]
+ has_many :user_approved_collections,
+ :through => :collection_items,
+ :source => :collection,
@houndci-bot
houndci-bot added a note May 28, 2016

Use the new Ruby 1.9 hash syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on an outdated diff May 28, 2016
lib/collectible.rb
@@ -7,6 +7,8 @@ def self.included(collectible)
accepts_nested_attributes_for :collection_items, :allow_destroy => true
has_many :approved_collection_items, :class_name => "CollectionItem", :as => :item,
:conditions => ['collection_items.user_approval_status = ? AND collection_items.collection_approval_status = ?', CollectionItem::APPROVED, CollectionItem::APPROVED]
+ has_many :user_approved_collection_items, :class_name => "CollectionItem", :as => :item,
+ :conditions => ['collection_items.user_approval_status = ?', CollectionItem::APPROVED]
@houndci-bot
houndci-bot added a note May 28, 2016

Align the elements of a hash literal if they span more than one line.
Use the new Ruby 1.9 hash syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on an outdated diff May 28, 2016
lib/collectible.rb
@@ -16,6 +18,10 @@ def self.included(collectible)
:through => :collection_items,
:source => :collection,
:conditions => ['collection_items.user_approval_status = ? AND collection_items.collection_approval_status = ?', CollectionItem::APPROVED, CollectionItem::APPROVED]
+ has_many :user_approved_collections,
+ :through => :collection_items,
@houndci-bot
houndci-bot added a note May 28, 2016

Align the parameters of a method call if they span more than one line.
Use the new Ruby 1.9 hash syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on an outdated diff May 28, 2016
lib/collectible.rb
@@ -7,6 +7,8 @@ def self.included(collectible)
accepts_nested_attributes_for :collection_items, :allow_destroy => true
has_many :approved_collection_items, :class_name => "CollectionItem", :as => :item,
:conditions => ['collection_items.user_approval_status = ? AND collection_items.collection_approval_status = ?', CollectionItem::APPROVED, CollectionItem::APPROVED]
+ has_many :user_approved_collection_items, :class_name => "CollectionItem", :as => :item,
@houndci-bot
houndci-bot added a note May 28, 2016

Use the new Ruby 1.9 hash syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@shalott shalott hound fixes
Signed-off-by: astolat shalott <[email protected]>
4e39c5a
@houndci-bot houndci-bot commented on the diff May 28, 2016
lib/collectible.rb
@@ -3,23 +3,29 @@ module Collectible
def self.included(collectible)
collectible.class_eval do
- has_many :collection_items, :as => :item, :dependent => :destroy, :inverse_of => :item
- accepts_nested_attributes_for :collection_items, :allow_destroy => true
- has_many :approved_collection_items, :class_name => "CollectionItem", :as => :item,
- :conditions => ['collection_items.user_approval_status = ? AND collection_items.collection_approval_status = ?', CollectionItem::APPROVED, CollectionItem::APPROVED]
+ has_many :collection_items, as: :item, dependent: :destroy, inverse_of: :item
+ accepts_nested_attributes_for :collection_items, allow_destroy: true
+ has_many :approved_collection_items, class_name: "CollectionItem", as: :item,
+ conditions: ['collection_items.user_approval_status = ? AND collection_items.collection_approval_status = ?', CollectionItem::APPROVED, CollectionItem::APPROVED]
+ has_many :user_approved_collection_items, class_name: "CollectionItem", as: :item,
+ conditions: ['collection_items.user_approval_status = ?', CollectionItem::APPROVED]
@houndci-bot
houndci-bot added a note May 28, 2016

Align the elements of a hash literal if they span more than one line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on the diff May 28, 2016
lib/collectible.rb
def update_anon_unrevealed
if self.respond_to?(:in_anon_collection) && self.respond_to?(:in_unrevealed_collection)
- self.in_anon_collection = !self.collection_items.select {|c| c.anonymous? }.empty?
- self.in_unrevealed_collection = !self.collection_items.select{|c| c.unrevealed? }.empty?
+ self.in_anon_collection = !self.user_approved_collection_items.select(&:anonymous?).empty?
@houndci-bot
houndci-bot added a note May 28, 2016

Redundant self detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on an outdated diff May 28, 2016
lib/collectible.rb
def set_anon_unrevealed
if self.respond_to?(:in_anon_collection) && self.respond_to?(:in_unrevealed_collection)
- self.in_anon_collection = !self.collections.select {|c| c.anonymous? }.empty?
- self.in_unrevealed_collection = !self.collections.select{|c| c.unrevealed? }.empty?
+ self.in_anon_collection = !self.user_approved_collections.select(&:anonymous?).empty?
+ self.in_unrevealed_collection = !self.user_approved_collections.select(&:unrevealed?).empty?
@houndci-bot
houndci-bot added a note May 28, 2016

Redundant self detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on an outdated diff May 28, 2016
lib/collectible.rb
def set_anon_unrevealed
if self.respond_to?(:in_anon_collection) && self.respond_to?(:in_unrevealed_collection)
- self.in_anon_collection = !self.collections.select {|c| c.anonymous? }.empty?
- self.in_unrevealed_collection = !self.collections.select{|c| c.unrevealed? }.empty?
+ self.in_anon_collection = !self.user_approved_collections.select(&:anonymous?).empty?
@houndci-bot
houndci-bot added a note May 28, 2016

Redundant self detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on the diff May 28, 2016
lib/collectible.rb
def update_anon_unrevealed
if self.respond_to?(:in_anon_collection) && self.respond_to?(:in_unrevealed_collection)
- self.in_anon_collection = !self.collection_items.select {|c| c.anonymous? }.empty?
- self.in_unrevealed_collection = !self.collection_items.select{|c| c.unrevealed? }.empty?
+ self.in_anon_collection = !self.user_approved_collection_items.select(&:anonymous?).empty?
+ self.in_unrevealed_collection = !self.user_approved_collection_items.select(&:unrevealed?).empty?
@houndci-bot
houndci-bot added a note May 28, 2016

Redundant self detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on the diff May 28, 2016
lib/collectible.rb
@@ -3,23 +3,29 @@ module Collectible
def self.included(collectible)
collectible.class_eval do
- has_many :collection_items, :as => :item, :dependent => :destroy, :inverse_of => :item
- accepts_nested_attributes_for :collection_items, :allow_destroy => true
- has_many :approved_collection_items, :class_name => "CollectionItem", :as => :item,
- :conditions => ['collection_items.user_approval_status = ? AND collection_items.collection_approval_status = ?', CollectionItem::APPROVED, CollectionItem::APPROVED]
+ has_many :collection_items, as: :item, dependent: :destroy, inverse_of: :item
+ accepts_nested_attributes_for :collection_items, allow_destroy: true
+ has_many :approved_collection_items, class_name: "CollectionItem", as: :item,
+ conditions: ['collection_items.user_approval_status = ? AND collection_items.collection_approval_status = ?', CollectionItem::APPROVED, CollectionItem::APPROVED]
@houndci-bot
houndci-bot added a note May 28, 2016

Align the elements of a hash literal if they span more than one line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on the diff May 28, 2016
lib/collectible.rb
if c.closed?
- errors.add(:base, ts("The collection %{name} is not currently open.", :name => name)) and return unless c.user_is_maintainer?(User.current_user) || old_collections.include?(c.id)
+ errors.add(:base, ts("The collection %{name} is not currently open.", name: name)) and return unless c.user_is_maintainer?(User.current_user) || old_collections.include?(c.id)
@houndci-bot
houndci-bot added a note May 28, 2016

Non-local exit from iterator, without return value. next, break, Array#find, Array#any?, etc. is preferred.
Use && instead of and.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on the diff May 28, 2016
lib/collectible.rb
@@ -29,9 +35,9 @@ def collections_to_add=(collection_names)
names = trim_collection_names(collection_names)
names.each do |name|
c = Collection.find_by_name(name)
- errors.add(:base, ts("We couldn't find the collection %{name}.", :name => name)) and return if c.nil?
+ errors.add(:base, ts("We couldn't find the collection %{name}.", name: name)) and return if c.nil?
@houndci-bot
houndci-bot added a note May 28, 2016

Non-local exit from iterator, without return value. next, break, Array#find, Array#any?, etc. is preferred.
Use && instead of and.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sarken
Organization for Transformative Works member
sarken commented May 29, 2016

I am unfortunately not sure why this is failing, but marking Needs Coder Action.

@shalott
Organization for Transformative Works member
shalott commented May 29, 2016

Yep a bunch of the tests need fixing because they expect the behavior we don't want (ie unapproved by user work being hidden/anon), can fix them Tuesday

@shalott shalott Fixed issue with the fix and added test to document desired behavior
Signed-off-by: astolat shalott <[email protected]>
edbb493
@houndci-bot houndci-bot commented on the diff Jun 1, 2016
lib/collectible.rb
def set_anon_unrevealed
if self.respond_to?(:in_anon_collection) && self.respond_to?(:in_unrevealed_collection)
- self.in_anon_collection = !self.collections.select {|c| c.anonymous? }.empty?
- self.in_unrevealed_collection = !self.collections.select{|c| c.unrevealed? }.empty?
+ # if we have collection items saved here then the collectible is not a new object
+ if self.collection_items.empty?
@houndci-bot
houndci-bot added a note Jun 1, 2016

Redundant self detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@shalott shalott whoops forgot the Gemfile.lock
Signed-off-by: astolat shalott <[email protected]>
c34f82e
@sarken sarken merged commit dfc37a7 into otwcode:master Jun 2, 2016

2 checks passed

Details continuous-integration/travis-ci/pr The Travis CI build passed
hound 9 violations found.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.