2013-12-28 15:45:21 +01:00
|
|
|
require 'test_helper'
|
|
|
|
|
2015-07-25 18:32:27 +02:00
|
|
|
# Verify the organisation creatino and mail workflow
|
2015-02-15 17:10:17 +01:00
|
|
|
class OrgaTest < ActiveSupport::TestCase
|
2015-07-25 18:32:27 +02:00
|
|
|
setup do
|
|
|
|
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
|
|
|
|
|
|
|
|
@config = Rails.application.config
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'propose orga' do
|
2016-10-31 22:41:20 +01:00
|
|
|
assert_difference 'ActionMailer::Base.deliveries.size', 2 do
|
2015-12-26 23:32:04 +01:00
|
|
|
Orga.create!(
|
|
|
|
kind: Kind.first,
|
|
|
|
name: 'Tested organisation',
|
|
|
|
url: 'http://example.com',
|
|
|
|
region: Region.first,
|
2017-07-01 17:17:26 +02:00
|
|
|
description: 'helo world',
|
2015-12-26 23:32:04 +01:00
|
|
|
contact: 'contact@example.com',
|
2016-11-07 22:30:44 +01:00
|
|
|
submitter: 'contact@example.com',
|
2016-12-17 16:59:11 +01:00
|
|
|
tag_list: 'hello world'
|
2015-12-26 23:32:04 +01:00
|
|
|
)
|
|
|
|
end
|
2015-07-25 18:32:27 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'set and send secret' do
|
|
|
|
@orga = orgas(:two)
|
|
|
|
assert_nil @orga.secret
|
2016-10-31 22:41:20 +01:00
|
|
|
assert_difference 'ActionMailer::Base.deliveries.size', 3 do
|
2015-07-25 18:32:27 +02:00
|
|
|
@orga.name = 'hop hop hop'
|
|
|
|
@orga.save!
|
|
|
|
end
|
|
|
|
assert_not_nil @orga.secret
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'edit orga' do
|
|
|
|
@orga = orgas(:one)
|
2016-10-31 22:41:20 +01:00
|
|
|
assert_difference 'ActionMailer::Base.deliveries.size', 2 do
|
2015-07-25 18:32:27 +02:00
|
|
|
@orga.name += ' addition added as an edit :)'
|
|
|
|
@orga.save!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'accept orga' do
|
|
|
|
@orga = orgas(:two)
|
2016-10-31 22:41:20 +01:00
|
|
|
assert_difference 'ActionMailer::Base.deliveries.size', 3 do
|
2015-07-25 18:32:27 +02:00
|
|
|
@orga.moderated = true
|
|
|
|
@orga.save!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'refuse orga' do
|
|
|
|
@orga = orgas(:two)
|
2016-10-31 22:41:20 +01:00
|
|
|
assert_difference 'ActionMailer::Base.deliveries.size', 2 do
|
2015-07-25 18:32:27 +02:00
|
|
|
@orga.destroy!
|
|
|
|
end
|
|
|
|
end
|
2013-12-28 15:45:21 +01:00
|
|
|
end
|