Merge pull request #456 from AyuntamientoMadrid/tracking_verified_users-399

Tracking verified users
This commit is contained in:
Enrique García
2015-09-10 13:20:00 +02:00
5 changed files with 40 additions and 5 deletions

View File

@@ -3,7 +3,7 @@ class StatsController < ApplicationController
skip_authorization_check
def show
@event_types = Ahoy::Event.select(:name).uniq.pluck(:name)
@event_types = Ahoy::Event.group(:name).count
end
private

View File

@@ -27,6 +27,7 @@ class Verification::SmsController < ApplicationController
@sms = Verification::Sms.new(sms_params.merge(user: current_user))
if @sms.verify?
current_user.update(confirmed_phone: current_user.unconfirmed_phone)
ahoy.track :level_2_user, user_id: current_user.id
if VerifiedUser.phone?(current_user)
current_user.update(verified_at: Time.now)

View File

@@ -10,13 +10,13 @@
<div class="small-12 medium-6 column">
<h3>Combined</h3>
<%= events_chart_tag @event_types, id: 'combined' %>
<%= events_chart_tag @event_types.keys, id: 'combined' %>
</div>
<div class="small-12">
<% @event_types.each do |event_type| %>
<h3><%= event_type.titleize %></h3>
<%= events_chart_tag event_type %>
<% @event_types.each do |event, count| %>
<h3><%= event.titleize %> (<%= count %>)</h3>
<%= events_chart_tag event %>
<% end %>
</div>
</div>

View File

@@ -0,0 +1,21 @@
require 'rails_helper'
feature 'Stats' do
scenario 'Level 2 user' do
admin = create(:administrator)
user = create(:user)
login_as(user)
visit account_path
click_link 'Verify my account'
verify_residence
confirm_phone
login_as(admin.user)
visit stats_path
expect(page).to have_content "Level 2 User (1)"
end
end

View File

@@ -110,4 +110,17 @@ module CommonActions
click_button 'Verify residence'
expect(page).to have_content 'Residence verified'
end
def confirm_phone
fill_in 'sms_phone', with: "611111111"
click_button 'Send'
expect(page).to have_content 'Security code confirmation'
user = User.last.reload
fill_in 'sms_confirmation_code', with: user.sms_confirmation_code
click_button 'Send'
expect(page).to have_content 'Correct code'
end
end