Sha256: f0962a50ee87076cbcd3e77642ff90a5dcde2acd2d950b1234edf8cf505f51fd

Contents?: true

Size: 1.84 KB

Versions: 11

Compression:

Stored size: 1.84 KB

Contents

require_relative '../test_helper.rb'
class UserTest < ActiveSupport::TestCase
  setup do
    @user = users(:basic)
  end
  test 'tagging a user' do
    @user.tag 'awesome'
    assert_tag 'awesome'
  end
  test 'untagging a user' do
    t = 'bad'
    @user.tag t
    assert_tag t
    @user.untag t
    assert_not_tag t
  end

  test 'resetting a password' do
    assert_true json_response(@user.reset_password)['worked']
  end

  test 'updating from dailycred' do
    dc = {
      email: 'hank@2.com',
      tags: ['hello','awesome'],
      referred: ['danny', 'betty'],
      username: 'hstove',
      created: 111222333,
      verified: false,
      admin: false,
      referred_by: 'marky',
      referred: ['chris', 'mike'],
      facebook: {
        id: 100203,
        email: 'hank@facebook.com'
      },
      provider: 'dailycred',
      token: 'ha243k',
      twitter: {
        screen_name: 'heynky'
      },
      google: {
        email: 'hstove@gg.com'
      },
      github: {
        repos: ['123','ruby on rails']
      },
      subscribed: false,
      display: 'hanky'
    }
    @user.update_from_dailycred dc
    dc.each do |k,v|
      assert_equal v, @user[k], "user should have value of |#{v}| for |#{k}| but was |#{@user[k].to_s}|"
    end
  end

  test 'firing an event' do
    assert_true json_response(@user.fire_event 'got tested')['worked']
  end

  test 'making a referral link' do
    id = @user.uid
    assert_equal @user.referral_link('http://me.com'), "https://www.dailycred.com/r/#{id}?redirect_uri=http://me.com"
  end

  def json_response response
    JSON.parse response.body
  end


  def assert_tag tag
    assert_true @user.tags.include?(tag), "user should have tag: #{tag} but has tags: #{@user.tags}"
  end
  def assert_not_tag tag
    assert_false @user.tags.include?(tag), "user should not have tag: #{tag} but has tags: #{@user.tags}"
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dailycred-0.1.7 dummy/test/unit/user_test.rb
dailycred-0.1.6 dummy/test/unit/user_test.rb
dailycred-0.1.5 dummy/test/unit/user_test.rb
dailycred-0.1.461 dummy/test/unit/user_test.rb
dailycred-0.1.46 dummy/test/unit/user_test.rb
dailycred-0.1.45 dummy/test/unit/user_test.rb
dailycred-0.1.44 dummy/test/unit/user_test.rb
dailycred-0.1.43 dummy/test/unit/user_test.rb
dailycred-0.1.42 dummy/test/unit/user_test.rb
dailycred-0.1.41 dummy/test/unit/user_test.rb
dailycred-0.1.4 dummy/test/unit/user_test.rb