forked from rapidftr/RapidFTR
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/kai-ramuenke/RapidFTR int…
…o kai-ramuenke-master
- Loading branch information
Showing
10 changed files
with
137 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,3 +103,6 @@ DEPENDENCIES | |
uuidtools (= 2.1.1) | ||
validatable (= 1.6.7) | ||
webrat (= 0.7.1) | ||
|
||
METADATA | ||
version: 1.0.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class MobileLoginEvent < Hash | ||
include CouchRest::CastedModel | ||
|
||
property :imei | ||
property :mobile_number | ||
property :timestamp | ||
|
||
def initialize properties | ||
super(properties) | ||
self[:timestamp] ||= Time.now | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div class="device-information"> | ||
<h3>Device Information</h3> | ||
<table> | ||
<tr> | ||
<th>Timestamp</th> | ||
<th>IMEI</th> | ||
<th>Mobile Number</th> | ||
</tr> | ||
|
||
|
||
<% @user.mobile_login_history.reverse.each do |event| %> | ||
<tr> | ||
<td><%= event[:timestamp] %></td> | ||
<td><%= event[:imei] %></td> | ||
<td><%= event[:mobile_number] %></td> | ||
</tr> | ||
<% end %> | ||
|
||
</table> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
<% @page_name = "Editing user: #{@user.full_name}" %> | ||
<%= render :partial => "edittable_user", :object => @user %> | ||
<%= render :partial => "edittable_user", :object => @user %> | ||
<%= render :partial => "mobile_login_history", :object => @user %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'spec_helper' | ||
|
||
describe Login do | ||
describe "authenticate" do | ||
it "should save imei on successful login" do | ||
imei = "1334" | ||
mobile_number = "555-555" | ||
|
||
user = mock(User).as_null_object | ||
User.stub(:find_by_user_name).and_return(user) | ||
user.stub(:authenticate).and_return true | ||
|
||
user.should_receive(:add_mobile_login_event).with(imei, mobile_number) | ||
user.should_receive(:save) | ||
|
||
params = {:imei => imei, :mobile_number => mobile_number} | ||
login = Login.new(params) | ||
login.authenticate_user | ||
end | ||
|
||
it "should not save mobile login event on failed authentication" do | ||
imei = "1334" | ||
mobile_number = "555-555" | ||
|
||
user = mock(User).as_null_object | ||
User.stub(:find_by_user_name).and_return(user) | ||
user.stub(:authenticate).and_return false | ||
|
||
user.should_not_receive(:add_mobile_login_event).with(imei, mobile_number) | ||
|
||
params = {:imei => imei, :mobile_number => mobile_number} | ||
login = Login.new(params) | ||
login.authenticate_user | ||
end | ||
|
||
it "should not save mobile login events for non-mobile logins" do | ||
user = mock(User).as_null_object | ||
User.stub(:find_by_user_name).and_return(user) | ||
user.stub(:authenticate).and_return true | ||
|
||
user.should_not_receive(:add_mobile_login_event) | ||
|
||
params = {} | ||
login = Login.new(params) | ||
login.authenticate_user | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters