Commit 1a02f3c6ab0ca332f77c89c810e7e85e5266ba1f
1 parent
4bf9d214
Exists in
master
Added functional tests
Showing
2 changed files
with
41 additions
and
2 deletions
Show diff stats
controllers/email_article_plugin_myprofile_controller.rb
@@ -6,9 +6,9 @@ class EmailArticlePluginMyprofileController < MyProfileController | @@ -6,9 +6,9 @@ class EmailArticlePluginMyprofileController < MyProfileController | ||
6 | if user.is_admin?(profile) | 6 | if user.is_admin?(profile) |
7 | article = Article.find(params[:id]) | 7 | article = Article.find(params[:id]) |
8 | EmailArticlePluginMyprofileController::Sender.deliver_mail(article) | 8 | EmailArticlePluginMyprofileController::Sender.deliver_mail(article) |
9 | - render :action => 'success' | 9 | + render :text => "Email sent to queue" |
10 | else | 10 | else |
11 | - render :action => 'fail' | 11 | + render :status => :forbidden, :text => "Forbidden user" |
12 | end | 12 | end |
13 | end | 13 | end |
14 | 14 |
test/functional/email_article_plugin_myprofile_controller_test.rb
0 → 100644
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | + | ||
3 | +class EmailArticlePluginMyprofileControllerTest < ActionController::TestCase | ||
4 | + | ||
5 | + def setup | ||
6 | + Environment.delete_all | ||
7 | + @environment = Environment.new(:name => 'testenv', :is_default => true) | ||
8 | + @environment.enabled_plugins = ['EmailArticlePlugin'] | ||
9 | + @environment.save! | ||
10 | + end | ||
11 | + | ||
12 | + should 'be able to deliver mail as profile admin' do | ||
13 | + @profile = Community.create!(:name => 'Sample community', :identifier => 'sample-community') | ||
14 | + @user = create_user('testinguser') | ||
15 | + login_as(@user.login) | ||
16 | + @profile.add_admin(@user.person) | ||
17 | + @article = @profile.articles.create!(:name => 'a test article', :last_changed_by => @user.person) | ||
18 | + @article.save | ||
19 | + get :send_email, :profile => @profile.identifier, :id => @article.id | ||
20 | + assert_response :success | ||
21 | + end | ||
22 | + | ||
23 | + should 'deny access to email article unless if profile admin' do | ||
24 | + @profile = Community.create!(:name => 'Another community', :identifier => 'another-community') | ||
25 | + @user = create_user('user-out-of-the-community') | ||
26 | + login_as(@user.login) | ||
27 | + @article = @profile.articles.create!(:name => 'a test article', :last_changed_by => @user.person) | ||
28 | + @article.save | ||
29 | + get :send_email, :profile => @profile.identifier, :id => @article.id | ||
30 | + assert_response 403 | ||
31 | + end | ||
32 | + | ||
33 | +end | ||
34 | + | ||
35 | + | ||
36 | + | ||
37 | + | ||
38 | + | ||
39 | + |