Commit 33b629d330eada04300aeed502379a031f35940c
1 parent
8e131944
Exists in
master
and in
29 other branches
unit tests: display_login_popup? and stylesheet?
Showing
1 changed file
with
31 additions
and
1 deletions
Show diff stats
plugins/require_auth_to_comment/test/unit/require_auth_to_comment_plugin_test.rb
... | ... | @@ -5,9 +5,10 @@ class RequireAuthToCommentPluginTest < ActiveSupport::TestCase |
5 | 5 | def setup |
6 | 6 | @plugin = RequireAuthToCommentPlugin.new |
7 | 7 | @comment = Comment.new |
8 | + @environment = fast_create(Environment) | |
8 | 9 | end |
9 | 10 | |
10 | - attr_reader :plugin, :comment | |
11 | + attr_reader :plugin, :comment, :environment | |
11 | 12 | |
12 | 13 | should 'reject comments for unauthenticated users' do |
13 | 14 | plugin.context = logged_in(false) |
... | ... | @@ -29,6 +30,35 @@ class RequireAuthToCommentPluginTest < ActiveSupport::TestCase |
29 | 30 | assert !comment.rejected? |
30 | 31 | end |
31 | 32 | |
33 | + should 'the default require type setting be hide_button' do | |
34 | + assert_equal 'hide_button', plugin.class.require_type_default_setting | |
35 | + end | |
36 | + | |
37 | + should 'display_login_popup? be false by default' do | |
38 | + context = mock(); | |
39 | + context.expects(:environment).returns(environment) | |
40 | + plugin.expects(:context).returns(context) | |
41 | + assert !plugin.display_login_popup? | |
42 | + end | |
43 | + | |
44 | + should 'display_login_popup? be true if require_type is defined as display_login_popup' do | |
45 | + context = mock(); | |
46 | + context.expects(:environment).returns(environment) | |
47 | + environment[:settings] = {:require_auth_to_comment_plugin => {:require_type => "display_login_popup"}} | |
48 | + plugin.expects(:context).returns(context) | |
49 | + assert plugin.display_login_popup? | |
50 | + end | |
51 | + | |
52 | + should 'not display stylesheet if login popup is active' do | |
53 | + plugin.expects(:display_login_popup?).returns(true) | |
54 | + assert !plugin.stylesheet? | |
55 | + end | |
56 | + | |
57 | + should 'display stylesheet if login popup is inactive' do | |
58 | + plugin.expects(:display_login_popup?).returns(false) | |
59 | + assert plugin.stylesheet? | |
60 | + end | |
61 | + | |
32 | 62 | protected |
33 | 63 | |
34 | 64 | def logged_in(boolean) | ... | ... |