require 'spec_helper'

describe "VoteFeatures" do
  before(:all) do
    @idea = create(:idea)
    @user = create(:user)
    @user.confirm!
    visit new_user_session_path
    fill_in "Email",    :with => "#{@user.email}"
    fill_in "Password", :with => "#{@user.password}"
    click_button "Sign in"
  end

  before(:each) do
    visit idea_path(@idea)
  end

  describe "Vote on an idea" do
    it "creates a new vote on an idea" do
      # puts Vote.find(@idea.id, @user.id).inspect

      click_link "Vote Up"
      expect(page).to have_content("Your vote was saved")
    end

  #   it "changes a vote's value down" do
  #     puts Vote.find(@idea.id, @user.id).inspect

  #     click_link "Vote Down"
  #     expect(page).to have_content("Your vote was saved")
  #   end

  #   it "changes a vote's value up" do
  #     puts Vote.find(@idea.id, @user.id).inspect

  #     click_link "Vote Up"
  #     expect(page).to have_content("Your vote was saved")
  #   end
  # end

  # describe "Remove a vote on an idea" do

  #   before(:all) do
  #     create(:vote, :user_id => @user.id, :idea_id => @idea.id)
  #   end

  #   it "removes a vote" do
  #     puts Vote.find(@idea.id, @user.id).inspect

  #     click_link "Delete Vote"
  #     expect(page).to have_content("Your vote was removed")
  #   end
  end
end

Add some (breaking) Vote feature specs
Add some (breaking) Vote feature specs

Create some feature specs for testing voting functionality. Currently,
tests break for one reason or another when all four are enabled.
One issue is that these specs expect to be executed in a particular
order, which they shouldn't be so they'll have to be adjusted.
Additionally, the votes controller appears to be behaving a little
strangely. The view rendered after voting doesn't always appear to be
up to date and needs to be refreshed.

TODO:
   * Fix Votes controller/Idea vote counting to render correct content
   * Fix Vote feature specs to perform the correct actions for testing
