Merge pull request #456 from AyuntamientoMadrid/tracking_verified_users-399
Tracking verified users
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
|
||||
21
spec/features/stats_spec.rb
Normal file
21
spec/features/stats_spec.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user