Skip to content

Commit

Permalink
adds specs for stats in queue
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoorai2000 committed Sep 9, 2015
1 parent dca7e1e commit b269034
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
45 changes: 45 additions & 0 deletions spec/features/active_jobs_spec.rb
@@ -0,0 +1,45 @@
require 'rails_helper'

feature 'ActiveJob' do
include ActiveJob::TestHelper

let(:admin) { create(:administrator) }

scenario 'use queue to track visits' do
debate = create(:debate)

visit debate_path(debate)

expect(enqueued_jobs.size).to eq(1)
perform_enqueued_jobs { StatsJob.perform_now(enqueued_jobs.first) }

login_as(admin.user)
visit stats_path

expect(page).to have_content 'Visits (1)'
end

scenario "use queue to track new debates" do
user = create(:user)

login_as(user)
visit new_debate_path

create_a_debate

expect(enqueued_jobs.size).to eq(2)

expect(enqueued_jobs.first[:args][1]["name"]).to eq("event")
expect(enqueued_jobs.last[:args][1]["name"]).to eq("visit")

perform_enqueued_jobs do
enqueued_jobs.each { |job| StatsJob.perform_now(job) }
end

login_as(admin.user)
visit stats_path

expect(page).to have_content 'Debate Created (1)'
end

end
11 changes: 11 additions & 0 deletions spec/support/common_actions.rb
Expand Up @@ -34,6 +34,17 @@ def reset_password
click_button 'Send me reset password instructions'
end

def create_a_debate
fill_in 'debate_title', with: 'Acabar con los desahucios'
fill_in 'debate_description', with: 'Esto es un tema muy importante porque...'
fill_in 'debate_captcha', with: correct_captcha_text
check 'debate_terms_of_service'

click_button 'Start a debate'

expect(page).to have_content 'Debate was successfully created.'
end

def comment_on(debate)
user = create(:user)

Expand Down

0 comments on commit b269034

Please sign in to comment.