Sha256: b357dfa04a4f43aad4b3823d765fe45aa80655fc0b8b7e5a7d946fbc2835d9ed

Contents?: true

Size: 493 Bytes

Versions: 10

Compression:

Stored size: 493 Bytes

Contents

module VotesControllerHelpers
  def create(voteable)
    xhr :post, :create, 
      vote: { 
        voteable_type: voteable.class.name,
        voteable_id: voteable.id,
        value: rand(0..1)
      } 
  end

  def update(vote, duplicate=false)
    xhr :patch, :update, id: vote.id, value: value(vote.value, duplicate)
  end

  def destroy(vote)
    xhr :delete, :destroy, id: vote.id
  end

  private
  def value(val, duplicate)
    return val if duplicate
    val == 1 ? 0 : 1
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
neutral-0.0.10 spec/support/votes_controller_helpers.rb
neutral-0.0.9 spec/support/votes_controller_helpers.rb
neutral-0.0.8 spec/support/votes_controller_helpers.rb
neutral-0.0.7 spec/support/votes_controller_helpers.rb
neutral-0.0.6 spec/support/votes_controller_helpers.rb
neutral-0.0.5 spec/support/votes_controller_helpers.rb
neutral-0.0.4 spec/support/votes_controller_helpers.rb
neutral-0.0.3 spec/support/votes_controller_helpers.rb
neutral-0.0.2 spec/support/votes_controller_helpers.rb
neutral-0.0.1 spec/support/votes_controller_helpers.rb