diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..06cf186d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: ruby +rvm: + - 2.0.0 +before_script: + - cp config/config.yml.sample config/config.yml + - cp config/database.yml.sample config/database.yml diff --git a/Gemfile b/Gemfile index 8f72fdae..d1cde0cc 100644 --- a/Gemfile +++ b/Gemfile @@ -56,6 +56,8 @@ gem 'octokit' # Use debugger # gem 'debugger', group: [:development, :test] +gem 'factory_girl_rails', group: [:development, :test] + group :development do gem 'capistrano', '~> 3.0' gem 'capistrano-rvm', github: 'capistrano/rvm' @@ -63,4 +65,4 @@ group :development do gem 'capistrano-rails' end -gem 'airbrake' \ No newline at end of file +gem 'airbrake' diff --git a/Gemfile.lock b/Gemfile.lock index 30bc5d1a..e6102703 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -78,6 +78,11 @@ GEM warden (~> 1.2.3) erubis (2.7.0) execjs (2.0.2) + factory_girl (4.3.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.3.0) + factory_girl (~> 4.3.0) + railties (>= 3.0.0) faraday (0.8.9) multipart-post (~> 1.2.0) haml (4.0.5) @@ -217,6 +222,7 @@ DEPENDENCIES capistrano-rvm! coffee-rails (~> 4.0.0) devise + factory_girl_rails haml-rails jbuilder (~> 1.2) jquery-rails diff --git a/README.md b/README.md index 87254791..8fd3cf95 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Tip4commit ========== -[![tip for next commit](http://tip4commit.com/projects/307.svg)](http://tip4commit.com/projects/307) +[![tip for next commit](http://tip4commit.com/projects/307.svg)](http://tip4commit.com/projects/307) [![Build Status](https://travis-ci.org/tip4commit/tip4commit.png?branch=master)](https://travis-ci.org/tip4commit/tip4commit) Donate bitcoins to open source projects or make commits and get tips for it. diff --git a/app/assets/stylesheets/justified-nav.css b/app/assets/stylesheets/justified-nav.css index 35e84503..0bfb4ac9 100644 --- a/app/assets/stylesheets/justified-nav.css +++ b/app/assets/stylesheets/justified-nav.css @@ -27,6 +27,7 @@ body { border: 1px solid #ccc; } .nav-justified > li > a { + margin-bottom: 0; padding-top: 15px; padding-bottom: 15px; color: #777; @@ -85,4 +86,4 @@ body { padding-left: 0; padding-right: 0; } -} \ No newline at end of file +} diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 65a6314d..88cc00b8 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -6,7 +6,7 @@ def blockchain_info_callback # todo: check if remote IP address belongs to blockchain.info if (params[:secret]!=CONFIG["blockchain_info"]["callback_secret"]) - render :text => "Invalid secret #{params}!" + render :text => "Invalid secret #{params}!" return end @@ -19,7 +19,7 @@ def blockchain_info_callback if deposit = Deposit.find_by_txid(params[:transaction_hash]) deposit.update_attribute(:confirmations, confirmations = params[:confirmations]) if !test - if confirmations.to_i > 6 + if confirmations.to_i > 6 render :text => "*ok*" else render :text => "Deposit #{deposit.id} updated!" @@ -27,8 +27,11 @@ def blockchain_info_callback return end - if project = Project.find_by_bitcoin_address(params[:input_address]) - ( + if params[:input_address] == CONFIG['deposit_address'] + # Deposit from the cold wallet + render :text => "*ok*" + elsif project = Project.find_by_bitcoin_address(params[:input_address]) + if !test deposit = Deposit.create({ project_id: project.id, txid: params[:transaction_hash], @@ -38,11 +41,12 @@ def blockchain_info_callback paid_out: 0, paid_out_at: Time.now }) - ) if !test - render :text => "Deposit #{deposit[:txid]} has been created!" + project.update_cache + end + render :text => "Deposit #{deposit[:txid]} has been created!" else render :text => "Project with deposit address #{params[:input_address]} is not found!" end end - + end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 18c28caf..bb1e7e68 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -4,6 +4,11 @@ class ProjectsController < ApplicationController def index @projects = Project.order(available_amount_cache: :desc, watchers_count: :desc, full_name: :asc).page(params[:page]).per(30) end + + def by_watchers + @projects = Project.order(watchers_count: :desc, available_amount_cache: :desc, full_name: :asc).page(params[:page]).per(30) + render "index" + end def show @project = Project.find params[:id] diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index a3ffad82..dbd06e18 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -2,7 +2,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController def github # render text: "#{request.env["omniauth.auth"].to_json}" info = request.env["omniauth.auth"]["info"] - @user = User.find_by :email => info["email"] + @user = User.find_by :nickname => info["nickname"] + @user ||= User.find_by :email => info["email"] unless @user generated_password = Devise.friendly_token.first(8) @user = User.create!( @@ -15,8 +16,8 @@ def github @user.name = info['name'] @user.image = info['image'] @user.save - + sign_in_and_redirect @user, :event => :authentication - set_flash_message(:notice, :success, :kind => "Github") if is_navigational_format? + set_flash_message(:notice, :success, :kind => "GitHub") if is_navigational_format? end -end \ No newline at end of file +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d4b6fb29..7fa6599e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,9 +1,7 @@ module ApplicationHelper def btc_human amount, options = {} nobr = options.has_key?(:nobr) ? options[:nobr] : true - currency = options[:currency] || false btc = "%.8f Ƀ" % to_btc(amount) - btc = "#{btc}" if currency btc = "#{btc}" if nobr btc.html_safe end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index e21ded23..54d1fe16 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -1,6 +1,6 @@ class UserMailer < ActionMailer::Base add_template_helper(ApplicationHelper) - + def new_tip user, tip @user = user @tip = tip diff --git a/app/models/project.rb b/app/models/project.rb index 2e5db9cd..9c34ada8 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2,7 +2,11 @@ class Project < ActiveRecord::Base has_many :deposits # todo: only confirmed deposits that have amount > paid_out has_many :tips + validates :full_name, uniqueness: true, presence: true + validates :github_id, uniqueness: true, presence: true + def update_github_info repo + self.github_id = repo.id self.name = repo.name self.full_name = repo.full_name self.source_full_name = repo.source.full_name rescue '' @@ -68,10 +72,15 @@ def tip_for commit user = User.create({ email: email, password: generated_password, - name: commit.commit.author.name + name: commit.commit.author.name, + nickname: (commit.author.login rescue nil) }) end + if commit.author && commit.author.login + user.update nickname: commit.author.login + end + # create tip tip = Tip.create({ project: self, @@ -98,7 +107,7 @@ def available_amount end def unconfirmed_amount - self.deposits.where(:confirmations => 0).map(&:available_amount).sum + self.deposits.where(:confirmations => 0).where('created_at > ?', 7.days.ago).map(&:available_amount).sum end def tips_paid_amount @@ -113,9 +122,35 @@ def next_tip_amount (CONFIG["tip"]*available_amount).ceil end + def update_cache + update available_amount_cache: available_amount + end + def self.update_cache find_each do |project| - project.update available_amount_cache: project.available_amount + project.update_cache + end + end + + def github_info + client = Octokit::Client.new \ + :client_id => CONFIG['github']['key'], + :client_secret => CONFIG['github']['secret'] + if github_id.present? + client.get("/repositories/#{github_id}") + else + client.repo(full_name) + end + end + + def update_info + begin + update_github_info(github_info) + rescue Octokit::BadGateway, Octokit::NotFound, Octokit::InternalServerError, + Errno::ETIMEDOUT, Net::ReadTimeout, Faraday::Error::ConnectionFailed => e + Rails.logger.info "Project ##{id}: #{e.class} happened" + rescue StandardError => e + Airbrake.notify(e) end end diff --git a/app/models/sendmany.rb b/app/models/sendmany.rb index a0f46092..64838a5c 100644 --- a/app/models/sendmany.rb +++ b/app/models/sendmany.rb @@ -1,4 +1,6 @@ class Sendmany < ActiveRecord::Base + has_many :tips + def send_transaction return if txid || is_error diff --git a/app/views/projects/index.html.haml b/app/views/projects/index.html.haml index d9345199..ad92332c 100644 --- a/app/views/projects/index.html.haml +++ b/app/views/projects/index.html.haml @@ -13,8 +13,8 @@ %tr %th Repository %th Description - %th Watchers - %th Balance + %th= link_to_unless_current 'Watchers', by_watchers_projects_path + %th= link_to_unless_current 'Balance', projects_path %th %tbody - @projects.each do |project| diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 29c8bb9a..43c890db 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -3,7 +3,7 @@ = @project.name - content_for :description do = @project.description - + %h1 = @project.full_name %small= link_to glyph(:github), @project.github_url, target: '_blank' @@ -20,7 +20,7 @@ %span(data-coingiving="title")= "[tip4commit] " + @project.full_name %span(data-coingiving="description")= @project.description %span(data-coingiving="bitcoin-address")= @project.bitcoin_address - %p #{100-(CONFIG["our_fee"]*100).round}% of deposited funds will be used to tip for new commits. + %p #{100-(CONFIG["our_fee"]*100).round}% of deposited funds will be used to tip for new commits. .col-md-8 - unless @project.description.blank? .well.well-sm= @project.description @@ -64,11 +64,11 @@ - if current_user - if current_user.bitcoin_address.blank? - Just + Just = link_to 'tell us', current_user - your bitcoin address. + your bitcoin address. - else - Just check your email or + Just check your email or %a{href: user_omniauth_authorize_path(:github)} Sign In. %h4 Promote #{@project.full_name} diff --git a/app/views/tips/index.html.haml b/app/views/tips/index.html.haml index 0b7093ad..ac4363c8 100644 --- a/app/views/tips/index.html.haml +++ b/app/views/tips/index.html.haml @@ -26,17 +26,18 @@ = link_to tip.user.full_name, "https://github.com/#{tip.user.nickname}", target: '_blank' - unless @project %td= link_to tip.project.full_name, tip.project - %td= link_to tip.commit[0..6], "https://github.com/#{tip.project.full_name}/commit/#{tip.commit}", target: :blank + %td= link_to tip.commit[0..6], "https://github.com/#{tip.project.full_name}/commit/#{tip.commit}", target: :blank %td= btc_human tip.amount %td - if tip.sendmany.nil? - if tip.refunded_at Refunded to project's deposit + - elsif tip.user.bitcoin_address.blank? + User didn't specify withdrawal address + - elsif tip.user.balance < CONFIG["min_payout"] + User's balance is below withdrawal threshold - else - - if tip.user.bitcoin_address.blank? - User didn't specify withdrawal address - - else - User's balance is below withdrawal threshold + Waiting for withdrawal - else - = link_to tip.sendmany.txid, "https://blockchain.info/tx/#{tip.sendmany.txid}", target: :blank - = paginate @tips \ No newline at end of file + = link_to tip.sendmany.txid, "https://blockchain.info/tx/#{tip.sendmany.txid}", target: :blank + = paginate @tips diff --git a/config/application.rb b/config/application.rb index 6495eac6..c560c739 100644 --- a/config/application.rb +++ b/config/application.rb @@ -26,3 +26,5 @@ class Application < Rails::Application config.autoload_paths += %W(#{config.root}/lib) end end + +I18n.enforce_available_locales = false diff --git a/config/config.yml.sample b/config/config.yml.sample index 992b3052..da55a320 100644 --- a/config/config.yml.sample +++ b/config/config.yml.sample @@ -1,6 +1,6 @@ github: key: "111111111111" - secret: "111111111111" + secret: "111111111111" blockchain_info: guid: "111111111111" @@ -30,4 +30,6 @@ smtp_settings: tip: 0.01 min_payout: 100000 -our_fee: 0.05 \ No newline at end of file +our_fee: 0.05 + +deposit_address: 1M4bS4gPyA6Kb8w7aXsgth9oUZWcRk73tQ diff --git a/config/environments/test.rb b/config/environments/test.rb index 799d7195..10065d4a 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -30,6 +30,8 @@ # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + config.action_mailer.raise_delivery_errors = false + config.action_mailer.default_url_options = { :host => "localhost:3000" } # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr diff --git a/config/routes.rb b/config/routes.rb index cc205fcd..191b38e3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,6 +9,9 @@ end end resources :projects, :only => [:show, :index, :create] do + collection do + get 'by_watchers' + end resources :tips, :only => [:index] end resources :tips, :only => [:index] diff --git a/db/migrate/20140207061855_add_github_id_to_projects.rb b/db/migrate/20140207061855_add_github_id_to_projects.rb new file mode 100644 index 00000000..9f2e8f24 --- /dev/null +++ b/db/migrate/20140207061855_add_github_id_to_projects.rb @@ -0,0 +1,5 @@ +class AddGithubIdToProjects < ActiveRecord::Migration + def change + add_column :projects, :github_id, :string + end +end diff --git a/db/migrate/20140209022632_change_projects_description.rb b/db/migrate/20140209022632_change_projects_description.rb new file mode 100644 index 00000000..a02592e2 --- /dev/null +++ b/db/migrate/20140209022632_change_projects_description.rb @@ -0,0 +1,8 @@ +class ChangeProjectsDescription < ActiveRecord::Migration + def up + change_column :projects, :description, :text, :limit => nil + end + def down + change_column :projects, :description, :string + end +end diff --git a/db/migrate/20140209041123_create_indexes_for_projects.rb b/db/migrate/20140209041123_create_indexes_for_projects.rb new file mode 100644 index 00000000..30f06922 --- /dev/null +++ b/db/migrate/20140209041123_create_indexes_for_projects.rb @@ -0,0 +1,6 @@ +class CreateIndexesForProjects < ActiveRecord::Migration + def change + add_index :projects, :full_name, :unique => true + add_index :projects, :github_id, :unique => true + end +end diff --git a/db/schema.rb b/db/schema.rb index aa2be27e..17121771 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140102095035) do +ActiveRecord::Schema.define(version: 20140209041123) do create_table "deposits", force: true do |t| t.integer "project_id" @@ -35,13 +35,17 @@ t.string "name" t.string "full_name" t.string "source_full_name" - t.string "description" + t.text "description" t.integer "watchers_count" t.string "language" t.string "last_commit" t.integer "available_amount_cache" + t.string "github_id" end + add_index "projects", ["full_name"], name: "index_projects_on_full_name", unique: true + add_index "projects", ["github_id"], name: "index_projects_on_github_id", unique: true + create_table "sendmanies", force: true do |t| t.string "txid" t.text "data" diff --git a/lib/bitcoin_tipper.rb b/lib/bitcoin_tipper.rb index da10ccb2..73e7486b 100644 --- a/lib/bitcoin_tipper.rb +++ b/lib/bitcoin_tipper.rb @@ -5,7 +5,7 @@ def self.work_forever end end - def self.work + def self.work withdraw = true Rails.logger.info "Traversing projects..." Project.find_each do |project| if project.available_amount > 0 @@ -14,20 +14,28 @@ def self.work end end - Rails.logger.info "Traversing users..." - is_sendmany_needed = false - User.find_each do |user| - if user.bitcoin_address.present? && user.balance > CONFIG["min_payout"] - is_sendmany_needed = true - Rails.logger.info "Sendmany is needed" - end + Rails.logger.info "Updating projects info..." + Project.order(:updated_at => :desc).last(10).each do |project| + Rails.logger.info " Project #{project.id} #{project.full_name}" + project.update_info end - self.create_sendmany if is_sendmany_needed + if withdraw + Rails.logger.info "Traversing users..." + is_sendmany_needed = false + User.find_each do |user| + if user.bitcoin_address.present? && user.balance > CONFIG["min_payout"] + is_sendmany_needed = true + Rails.logger.info "Sendmany is needed" + end + end + + self.create_sendmany if is_sendmany_needed - Rails.logger.info "Traversing sendmanies..." - Sendmany.where(txid: nil).each do |sendmany| - sendmany.send_transaction + Rails.logger.info "Traversing sendmanies..." + Sendmany.where(txid: nil).each do |sendmany| + sendmany.send_transaction + end end Rails.logger.info "Refunding unclaimed tips..." @@ -47,7 +55,7 @@ def self.create_sendmany outs = {} User.find_each do |user| if user.bitcoin_address.present? && user.balance > CONFIG["min_payout"] - user.tips.unpaid.each do |tip| + user.tips.unpaid.each do |tip| tip.update_attribute :sendmany_id, sendmany.id outs[user.bitcoin_address] = outs[user.bitcoin_address].to_i + tip.amount end @@ -55,7 +63,7 @@ def self.create_sendmany end sendmany.update_attribute :data, outs.to_json Rails.logger.info " #{sendmany.inspect}" - end + end end -end \ No newline at end of file +end diff --git a/test/controllers/projects_controller_test.rb b/test/controllers/projects_controller_test.rb index 636444b0..711941be 100644 --- a/test/controllers/projects_controller_test.rb +++ b/test/controllers/projects_controller_test.rb @@ -5,10 +5,4 @@ class ProjectsControllerTest < ActionController::TestCase get :index assert_response :success end - - test "should get show" do - get :show - assert_response :success - end - end diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index 54ba7d94..b15265a6 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -1,14 +1,9 @@ require 'test_helper' class UsersControllerTest < ActionController::TestCase - test "should get show" do - get :show - assert_response :success + test "should redirect if not loggedd in" do + create(:user) + get :show, {:id => 1} + assert_response :redirect end - - test "should get update" do - get :update - assert_response :success - end - end diff --git a/test/factories/deposits.rb b/test/factories/deposits.rb new file mode 100644 index 00000000..f3a732ee --- /dev/null +++ b/test/factories/deposits.rb @@ -0,0 +1,10 @@ +FactoryGirl.define do + factory :deposit do + association :project + txid "txid" + confirmations 1 + duration 1 + paid_out 1 + paid_out_at "2013-10-19 23:01:22" + end +end diff --git a/test/factories/projects.rb b/test/factories/projects.rb new file mode 100644 index 00000000..aa0ea185 --- /dev/null +++ b/test/factories/projects.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :project do + url "MyString" + full_name "test/test" + github_id "1234567890" + bitcoin_address "bitcoin_address" + end +end diff --git a/test/factories/sendmanies.rb b/test/factories/sendmanies.rb new file mode 100644 index 00000000..6cf19257 --- /dev/null +++ b/test/factories/sendmanies.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :sendmany do + txid "txid" + data "MyText" + result "MyString" + is_error false + end +end diff --git a/test/factories/tips.rb b/test/factories/tips.rb new file mode 100644 index 00000000..412b81c0 --- /dev/null +++ b/test/factories/tips.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :tip do + association :user + association :project + amount 1 + end +end diff --git a/test/factories/users.rb b/test/factories/users.rb new file mode 100644 index 00000000..e083293a --- /dev/null +++ b/test/factories/users.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :user do + email "john@doge.com" + password "password" + login_token "login_token" + end +end diff --git a/test/fixtures/.keep b/test/fixtures/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/deposits.yml b/test/fixtures/deposits.yml deleted file mode 100644 index 0b8407f8..00000000 --- a/test/fixtures/deposits.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -one: - project_id: - txid: MyString - confirmations: 1 - duration: 1 - paid_out: 1 - paid_out_at: 2013-10-19 23:01:22 - -two: - project_id: - txid: MyString - confirmations: 1 - duration: 1 - paid_out: 1 - paid_out_at: 2013-10-19 23:01:22 diff --git a/test/fixtures/projects.yml b/test/fixtures/projects.yml deleted file mode 100644 index 51df7832..00000000 --- a/test/fixtures/projects.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -one: - url: MyString - bitcoin_address: MyString - -two: - url: MyString - bitcoin_address: MyString diff --git a/test/fixtures/sendmanies.yml b/test/fixtures/sendmanies.yml deleted file mode 100644 index e6dd6dd9..00000000 --- a/test/fixtures/sendmanies.yml +++ /dev/null @@ -1,13 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -one: - txid: MyString - data: MyText - result: MyString - is_error: false - -two: - txid: MyString - data: MyText - result: MyString - is_error: false diff --git a/test/fixtures/tips.yml b/test/fixtures/tips.yml deleted file mode 100644 index 1f9726c4..00000000 --- a/test/fixtures/tips.yml +++ /dev/null @@ -1,13 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -one: - user_id: - amount: 1 - sendmany_id: - refunded_at: false - -two: - user_id: - amount: 1 - sendmany_id: - refunded_at: false diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml deleted file mode 100644 index c63aac0b..00000000 --- a/test/fixtures/users.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/mailers/user_mailer_test.rb b/test/mailers/user_mailer_test.rb index 19ab1f83..10b70006 100644 --- a/test/mailers/user_mailer_test.rb +++ b/test/mailers/user_mailer_test.rb @@ -2,11 +2,12 @@ class UserMailerTest < ActionMailer::TestCase test "new_tip" do - mail = UserMailer.new_tip - assert_equal "New tip", mail.subject - assert_equal ["to@example.org"], mail.to - assert_equal ["from@example.com"], mail.from - assert_match "Hi", mail.body.encoded + tip = build(:tip) + + mail = UserMailer.new_tip tip.user, tip + assert_equal "You received a tip for your commit", mail.subject + assert_equal ["john@doge.com"], mail.to + assert_match "Hello", mail.body.encoded end end diff --git a/test/test_helper.rb b/test/test_helper.rb index bc7e05d7..3251a053 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -9,7 +9,12 @@ class ActiveSupport::TestCase # # Note: You'll currently still have to declare fixtures explicitly in integration tests # -- they do not yet inherit this setting - fixtures :all + # fixtures :all # Add more helper methods to be used by all tests here... + include FactoryGirl::Syntax::Methods +end + +class ActionController::TestCase + include Devise::TestHelpers end