Commit 76ccdfde

mo khan <mo@mokhan.ca>
2013-07-06 11:12:41
use name instead of email when posting a comment via disqus
1 parent 9ed0f15
Changed files (2)
app/helpers/application_helper.rb
@@ -18,7 +18,7 @@ module ApplicationHelper
   end
 
   def disqus_auth(user = current_user)
-    data = { id: user.id, username: user.email, email: user.email }.to_json
+    data = { id: user.id, username: user.name, email: user.email }.to_json
     message = Base64.encode64(data).gsub("\n", "")
     timestamp = Time.now.to_i
     signature = OpenSSL::HMAC.hexdigest('sha1', ENV['DISQUS_SECRET_KEY'], "#{message} #{timestamp}")
spec/helpers/application_helper_spec.rb
@@ -2,10 +2,10 @@ require "spec_helper"
 
 describe ApplicationHelper do
   describe :disqus_auth do
-    let(:user) { OpenStruct.new(id: 1, email: 'test@cakeside.com') }
+    let(:user) { OpenStruct.new(id: 1, name: 'mo', email: 'test@cakeside.com') }
 
     before :each do
-      data = { id: user.id, username: user.email, email: user.email }.to_json
+      data = { id: user.id, username: user.name, email: user.email }.to_json
       message = Base64.encode64(data).gsub("\n", "")
       timestamp = Time.now.to_i
       secret = ENV['DISQUS_SECRET_KEY'] = 'secret'