Permalink
Browse files

Cleared out tests

  • Loading branch information...
1 parent 738b72b commit 7ad650e463bd9d7d1e76779f7c88271006db5d0d @xntrik xntrik committed Jan 22, 2012
Showing with 0 additions and 1,469 deletions.
  1. +0 −48 test/generators_test.rb
  2. +0 −207 test/integration/invitation_test.rb
  3. +0 −48 test/integration_tests_helper.rb
  4. +0 −59 test/mailers/invitation_mail_test.rb
  5. +0 −33 test/model_tests_helper.rb
  6. +0 −372 test/models/invitable_test.rb
  7. +0 −74 test/models_test.rb
  8. +0 −4 test/orm/active_record.rb
  9. +0 −10 test/orm/mongoid.rb
  10. +0 −6 test/rails_app/app/controllers/admins_controller.rb
  11. +0 −3 test/rails_app/app/controllers/application_controller.rb
  12. +0 −6 test/rails_app/app/controllers/free_invitations_controller.rb
  13. +0 −4 test/rails_app/app/controllers/home_controller.rb
  14. +0 −12 test/rails_app/app/controllers/users_controller.rb
  15. +0 −2 test/rails_app/app/helpers/application_helper.rb
  16. +0 −5 test/rails_app/app/models/admin.rb
  17. +0 −5 test/rails_app/app/models/octopussy.rb
  18. +0 −15 test/rails_app/app/models/user.rb
  19. +0 −12 test/rails_app/app/views/admins/new.html.erb
  20. +0 −12 test/rails_app/app/views/free_invitations/new.html.erb
  21. 0 test/rails_app/app/views/home/index.html.erb
  22. +0 −16 test/rails_app/app/views/layouts/application.html.erb
  23. +0 −15 test/rails_app/app/views/users/invitations/new.html.erb
  24. +0 −4 test/rails_app/config.ru
  25. +0 −25 test/rails_app/config/application.rb
  26. +0 −11 test/rails_app/config/boot.rb
  27. +0 −22 test/rails_app/config/database.yml
  28. +0 −5 test/rails_app/config/environment.rb
  29. +0 −26 test/rails_app/config/environments/development.rb
  30. +0 −49 test/rails_app/config/environments/production.rb
  31. +0 −35 test/rails_app/config/environments/test.rb
  32. +0 −7 test/rails_app/config/initializers/backtrace_silencers.rb
  33. +0 −184 test/rails_app/config/initializers/devise.rb
  34. +0 −10 test/rails_app/config/initializers/inflections.rb
  35. +0 −5 test/rails_app/config/initializers/mime_types.rb
  36. +0 −7 test/rails_app/config/initializers/secret_token.rb
  37. +0 −8 test/rails_app/config/initializers/session_store.rb
  38. +0 −10 test/rails_app/config/locales/en.yml
  39. +0 −12 test/rails_app/config/mongoid.yml
  40. +0 −9 test/rails_app/config/routes.rb
  41. +0 −20 test/rails_app/db/migrate/20100401102949_create_tables.rb
  42. +0 −6 test/rails_app/script/rails
  43. +0 −20 test/routes_test.rb
  44. +0 −5 test/support/locale/en.yml
  45. +0 −21 test/test_helper.rb
View
@@ -1,48 +0,0 @@
-$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
-require 'test_helper'
-require 'rails/generators'
-require 'generators/devise_invitable/devise_invitable_generator'
-
-class GeneratorsTest < ActiveSupport::TestCase
- RAILS_APP_PATH = File.expand_path("../rails_app", __FILE__)
-
- test "rails g should include the 3 generators" do
- @output = `cd #{RAILS_APP_PATH} && rails g`
- assert @output.match(%r|DeviseInvitable:\n devise_invitable\n devise_invitable:install\n devise_invitable:views|)
- end
-
- test "rails g devise_invitable:install" do
- @output = `cd #{RAILS_APP_PATH} && rails g devise_invitable:install -p`
- assert @output.match(%r{(inject|insert).+ config/initializers/devise\.rb\n})
- assert @output.match(%r|create.+ config/locales/devise_invitable\.en\.yml\n|)
- end
-
- test "rails g devise_invitable:views not scoped" do
- @output = `cd #{RAILS_APP_PATH} && rails g devise_invitable:views -p`
- assert @output.match(%r|create.+ app/views/devise/invitations\n|)
- assert @output.match(%r|create.+ app/views/devise/invitations/edit\.html\.erb\n|)
- assert @output.match(%r|create.+ app/views/devise/invitations/new\.html\.erb\n|)
- assert @output.match(%r|create.+ app/views/devise/mailer\n|)
- assert @output.match(%r|create.+ app/views/devise/mailer/invitation_instructions\.html\.erb\n|)
- end
-
- test "rails g devise_invitable:views scoped" do
- @output = `cd #{RAILS_APP_PATH} && rails g devise_invitable:views octopussies -p`
- assert @output.match(%r|create.+ app/views/octopussies/invitations\n|)
- assert @output.match(%r|create.+ app/views/octopussies/invitations/edit\.html\.erb\n|)
- assert @output.match(%r|create.+ app/views/octopussies/invitations/new\.html\.erb\n|)
- assert @output.match(%r|create.+ app/views/octopussies/mailer\n|)
- assert @output.match(%r|create.+ app/views/octopussies/mailer/invitation_instructions\.html\.erb\n|)
- end
-
- test "rails g devise_invitable Octopussy" do
- @output = `cd #{RAILS_APP_PATH} && rails g devise_invitable Octopussy -p`
- assert @output.match(%r{(inject|insert).+ app/models/octopussy\.rb\n})
- assert @output.match(%r|invoke.+ #{DEVISE_ORM}\n|)
- if DEVISE_ORM == :active_record
- assert @output.match(%r|create.+ db/migrate/\d{14}_devise_invitable_add_to_octopussies\.rb\n|)
- elsif DEVISE_ORM == :mongoid
- assert !@output.match(%r|create.+ db/migrate/\d{14}_devise_invitable_add_to_octopussies\.rb\n|)
- end
- end
-end
@@ -1,207 +0,0 @@
-require 'test_helper'
-require 'integration_tests_helper'
-
-class InvitationTest < ActionDispatch::IntegrationTest
- def teardown
- Capybara.reset_sessions!
- end
-
- def send_invitation(url = new_user_invitation_path, &block)
- visit url
-
- fill_in 'user_email', :with => 'user@test.com'
- yield if block_given?
- click_button 'Send an invitation'
- end
-
- def set_password(options={}, &block)
- unless options[:visit] == false
- visit accept_user_invitation_path(:invitation_token => options[:invitation_token])
- end
-
- fill_in 'user_password', :with => '987654321'
- fill_in 'user_password_confirmation', :with => '987654321'
- yield if block_given?
- click_button 'Set my password'
- end
-
- test 'not authenticated user should be able to send a free invitation' do
- send_invitation new_free_invitation_path
- assert_equal root_path, current_path
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
- end
-
- test 'not authenticated user should not be able to send an invitation' do
- get new_user_invitation_path
- assert_redirected_to new_user_session_path
- end
-
- test 'authenticated user should be able to send an invitation' do
- sign_in_as_user
-
- send_invitation
- assert_equal root_path, current_path
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
- end
-
- test 'authenticated user with existing email should receive an error message' do
- user = create_full_user
- sign_in_as_user(user)
- send_invitation do
- fill_in 'user_email', :with => user.email
- end
-
- assert_equal user_invitation_path, current_path
- assert page.has_css?("input[type=text][value='#{user.email}']")
- assert page.has_css?('#error_explanation li', :text => 'Email has already been taken')
- end
-
- test 'authenticated user should not be able to visit edit invitation page' do
- sign_in_as_user
-
- visit accept_user_invitation_path
-
- assert_equal root_path, current_path
- end
-
- test 'not authenticated user with invalid invitation token should not be able to set his password' do
- user = User.invite!(:email => "valid@email.com")
- user.accept_invitation!
- visit accept_user_invitation_path(:invitation_token => 'invalid_token')
-
- assert_equal root_path, current_path
- assert page.has_css?('p#alert', :text => 'The invitation token provided is not valid!')
- end
-
- test 'not authenticated user with valid invitation token but invalid password should not be able to set his password' do
- user = User.invite!(:email => "valid@email.com")
- set_password :invitation_token => user.invitation_token do
- fill_in 'Password confirmation', :with => 'other_password'
- end
- assert_equal user_invitation_path, current_path
- assert page.has_css?('#error_explanation li', :text => 'Password doesn\'t match confirmation')
- assert_blank user.encrypted_password
- end
-
- test 'not authenticated user with valid data should be able to change his password' do
- user = User.invite!(:email => "valid@email.com")
- set_password :invitation_token => user.invitation_token
-
- assert_equal root_path, current_path
- assert page.has_css?('p#notice', :text => 'Your password was set successfully. You are now signed in.')
- assert user.reload.valid_password?('987654321')
- end
-
- test 'after entering invalid data user should still be able to set his password' do
- user = User.invite!(:email => "valid@email.com")
- set_password :invitation_token => user.invitation_token do
- fill_in 'Password confirmation', :with => 'other_password'
- end
- assert_equal user_invitation_path, current_path
- assert page.has_css?('#error_explanation')
- assert_blank user.encrypted_password
-
- set_password :visit => false
- assert page.has_css?('p#notice', :text => 'Your password was set successfully. You are now signed in.')
- assert user.reload.valid_password?('987654321')
- end
-
- test 'sign in user automatically after setting it\'s password' do
- user = User.invite!(:email => "valid@email.com")
- set_password :invitation_token => user.invitation_token
- assert_equal root_path, current_path
- end
-
- test 'user with invites left should be able to send an invitation' do
- User.stubs(:invitation_limit).returns(1)
-
- user = create_full_user
- user.invitation_limit = 1
- user.save!
- sign_in_as_user(user)
-
- assert_difference 'User.count' do
- send_invitation
- end
- assert_equal root_path, current_path
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
- user = User.find(user.id)
- assert !user.has_invitations_left?
- end
-
- test 'user with no invites left should not be able to send an invitation' do
- User.stubs(:invitation_limit).returns(1)
-
- user = create_full_user
- user.invitation_limit = 0
- user.save!
- sign_in_as_user(user)
-
- assert_no_difference 'User.count' do
- send_invitation
- end
- assert_equal user_invitation_path, current_path
- assert page.has_css?('p#alert', :text => 'No invitations remaining')
- end
-
- test 'user with nil invitation_limit should default to User.invitation_limit' do
- User.stubs(:invitation_limit).returns(3)
-
- user = create_full_user
- assert_nil user[:invitation_limit]
- assert_equal 3, user.invitation_limit
- sign_in_as_user(user)
-
- send_invitation
- assert_equal root_path, current_path
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
- user = User.find(user.id)
- assert_equal 2, user.invitation_limit
- end
-
- test 'should not decrement invitation limit when trying to invite again a user which is invited' do
- User.stubs(:invitation_limit).returns(3)
-
- user = create_full_user
- assert_nil user[:invitation_limit]
- assert_equal 3, user.invitation_limit
- sign_in_as_user(user)
-
- send_invitation
- assert_equal root_path, current_path
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
- user = User.find(user.id)
- assert_equal 2, user.invitation_limit
-
- send_invitation
- assert_equal root_path, current_path
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
- user = User.find(user.id)
- assert_equal 2, user.invitation_limit
- end
-
- test 'invited_by should be set when user invites someone' do
- user = create_full_user
- sign_in_as_user(user)
- send_invitation
-
- invited_user = User.where(:email => 'user@test.com').first
- assert invited_user
- assert_equal user, invited_user.invited_by
- end
-
- test 'authenticated user should not be able to send an admin invitation' do
- sign_in_as_user
-
- get new_admin_path
- assert_redirected_to new_admin_session_path
- end
-
- test 'authenticated admin should be able to send an admin invitation' do
- sign_in_as_user Admin.create(:email => 'admin@test.com', :password => '123456', :password_confirmation => '123456')
-
- send_invitation new_admin_path
- assert_equal root_path, current_path
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
- end
-end
@@ -1,48 +0,0 @@
-class ActionController::IntegrationTest
-
- def warden
- request.env['warden']
- end
-
- def create_full_user
- @user ||= begin
- user = User.create!(
- :username => 'usertest',
- :email => 'fulluser@test.com',
- :password => '123456',
- :password_confirmation => '123456',
- :created_at => Time.now.utc
- )
- user.confirm!
- user
- end
- end
-
- def sign_in_as_user(user = nil)
- user ||= create_full_user
- resource_name = user.class.name.underscore
- visit send("new_#{resource_name}_session_path")
- fill_in "#{resource_name}_email", :with => user.email
- fill_in "#{resource_name}_password", :with => user.password
- click_button 'Sign in'
- end
-
- # Fix assert_redirect_to in integration sessions because they don't take into
- # account Middleware redirects.
- #
- def assert_redirected_to(url)
- assert [301, 302].include?(@integration_session.status),
- "Expected status to be 301 or 302, got #{@integration_session.status}"
-
- url = prepend_host(url)
- location = prepend_host(@integration_session.headers["Location"])
- assert_equal url, location
- end
-
- protected
-
- def prepend_host(url)
- url = "http://#{request.host}#{url}" if url[0] == ?/
- url
- end
-end
@@ -1,59 +0,0 @@
-require 'test_helper'
-require 'model_tests_helper'
-
-class InvitationMailTest < ActionMailer::TestCase
-
- def setup
- setup_mailer
- Devise.mailer_sender = 'test@example.com'
- end
-
- def user
- @user ||= User.invite!(:email => "valid@email.com")
- end
-
- def mail
- @mail ||= begin
- user
- ActionMailer::Base.deliveries.last
- end
- end
-
- test 'email sent after reseting the user password' do
- assert_not_nil mail
- end
-
- test 'content type should be set to html' do
- assert_equal 'text/html; charset=UTF-8', mail.content_type
- end
-
- test 'send invitation to the user email' do
- assert_equal [user.email], mail.to
- end
-
- test 'setup sender from configuration' do
- assert_equal ['test@example.com'], mail.from
- end
-
- test 'setup subject from I18n' do
- store_translations :en, :devise => { :mailer => { :invitation_instructions => { :subject => 'Localized Invitation' } } } do
- assert_equal 'Localized Invitation', mail.subject
- end
- end
-
- test 'subject namespaced by model' do
- store_translations :en, :devise => { :mailer => { :invitation_instructions => { :user_subject => 'User Invitation' } } } do
- assert_equal 'User Invitation', mail.subject
- end
- end
-
- test 'body should have user info' do
- assert_match /#{user.email}/, mail.body.decoded
- end
-
- test 'body should have link to confirm the account' do
- host = ActionMailer::Base.default_url_options[:host]
- invitation_url_regexp = %r{<a href=\"http://#{host}/users/invitation/accept\?invitation_token=#{user.invitation_token}">}
- assert_match invitation_url_regexp, mail.body.decoded
- end
-end
View
@@ -1,33 +0,0 @@
-class ActiveSupport::TestCase
- def setup_mailer
- ActionMailer::Base.deliveries = []
- end
-
- def store_translations(locale, translations, &block)
- begin
- I18n.backend.store_translations locale, translations
- yield
- ensure
- I18n.reload!
- end
- end
-
- # Helpers for creating new users
- #
- def generate_unique_email
- @@email_count ||= 0
- @@email_count += 1
- "test#{@@email_count}@email.com"
- end
-
- def valid_attributes(attributes={})
- { :email => generate_unique_email,
- :password => '123456',
- :password_confirmation => '123456' }.update(attributes)
- end
-
- def new_user(attributes={})
- User.new(valid_attributes(attributes))
- end
-
-end
Oops, something went wrong.

0 comments on commit 7ad650e

Please sign in to comment.