uniform_notifier 1.10.0 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +1 -1
- data/CHANGELOG.md +18 -0
- data/Gemfile +3 -1
- data/README.md +95 -77
- data/Rakefile +13 -11
- data/lib/uniform_notifier.rb +38 -6
- data/lib/uniform_notifier/airbrake.rb +3 -3
- data/lib/uniform_notifier/base.rb +17 -14
- data/lib/uniform_notifier/bugsnag.rb +4 -7
- data/lib/uniform_notifier/customized_logger.rb +6 -4
- data/lib/uniform_notifier/errors.rb +3 -1
- data/lib/uniform_notifier/growl.rb +20 -21
- data/lib/uniform_notifier/honeybadger.rb +5 -4
- data/lib/uniform_notifier/javascript_alert.rb +7 -3
- data/lib/uniform_notifier/javascript_console.rb +18 -14
- data/lib/uniform_notifier/rails_logger.rb +3 -1
- data/lib/uniform_notifier/raise.rb +4 -2
- data/lib/uniform_notifier/rollbar.rb +8 -1
- data/lib/uniform_notifier/sentry.rb +21 -0
- data/lib/uniform_notifier/slack.rb +20 -22
- data/lib/uniform_notifier/terminal_notifier.rb +24 -0
- data/lib/uniform_notifier/version.rb +3 -1
- data/lib/uniform_notifier/xmpp.rb +25 -24
- data/spec/spec_helper.rb +8 -6
- data/spec/uniform_notifier/airbrake_spec.rb +12 -10
- data/spec/uniform_notifier/base_spec.rb +12 -14
- data/spec/uniform_notifier/bugsnag_spec.rb +33 -19
- data/spec/uniform_notifier/customized_logger_spec.rb +9 -7
- data/spec/uniform_notifier/growl_spec.rb +41 -23
- data/spec/uniform_notifier/honeybadger_spec.rb +12 -10
- data/spec/uniform_notifier/javascript_alert_spec.rb +29 -9
- data/spec/uniform_notifier/javascript_console_spec.rb +55 -17
- data/spec/uniform_notifier/rails_logger_spec.rb +9 -7
- data/spec/uniform_notifier/raise_spec.rb +15 -16
- data/spec/uniform_notifier/rollbar_spec.rb +15 -6
- data/spec/uniform_notifier/sentry_spec.rb +27 -0
- data/spec/uniform_notifier/slack_spec.rb +12 -8
- data/spec/uniform_notifier/terminal_notifier_spec.rb +27 -0
- data/spec/uniform_notifier/xmpp_spec.rb +21 -15
- data/uniform_notifier.gemspec +24 -17
- metadata +33 -25
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
|
5
|
+
require 'uniform_notifier'
|
6
|
+
require 'ruby-growl'
|
7
|
+
require 'xmpp4r'
|
8
|
+
require 'slack-notifier'
|
9
|
+
require 'rspec'
|
@@ -1,25 +1,27 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
2
4
|
|
3
5
|
class Airbrake
|
4
6
|
# mock Airbrake
|
5
7
|
end
|
6
8
|
|
7
9
|
RSpec.describe UniformNotifier::AirbrakeNotifier do
|
8
|
-
it
|
9
|
-
expect(UniformNotifier::AirbrakeNotifier.out_of_channel_notify(:
|
10
|
+
it 'should not notify airbrake' do
|
11
|
+
expect(UniformNotifier::AirbrakeNotifier.out_of_channel_notify(title: 'notify airbrake')).to be_nil
|
10
12
|
end
|
11
13
|
|
12
|
-
it
|
13
|
-
expect(Airbrake).to receive(:notify).with(UniformNotifier::Exception.new(
|
14
|
+
it 'should notify airbrake' do
|
15
|
+
expect(Airbrake).to receive(:notify).with(UniformNotifier::Exception.new('notify airbrake'), {})
|
14
16
|
|
15
17
|
UniformNotifier.airbrake = true
|
16
|
-
UniformNotifier::AirbrakeNotifier.out_of_channel_notify(:
|
18
|
+
UniformNotifier::AirbrakeNotifier.out_of_channel_notify(title: 'notify airbrake')
|
17
19
|
end
|
18
20
|
|
19
|
-
it
|
20
|
-
expect(Airbrake).to receive(:notify).with(UniformNotifier::Exception.new(
|
21
|
+
it 'should notify airbrake' do
|
22
|
+
expect(Airbrake).to receive(:notify).with(UniformNotifier::Exception.new('notify airbrake'), foo: :bar)
|
21
23
|
|
22
|
-
UniformNotifier.airbrake = { :
|
23
|
-
UniformNotifier::AirbrakeNotifier.out_of_channel_notify(
|
24
|
+
UniformNotifier.airbrake = { foo: :bar }
|
25
|
+
UniformNotifier::AirbrakeNotifier.out_of_channel_notify('notify airbrake')
|
24
26
|
end
|
25
27
|
end
|
@@ -1,22 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
RSpec.describe UniformNotifier::Base do
|
4
|
-
context
|
5
|
-
before
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
expect(UniformNotifier::Base).to receive(:_inline_notify).once.with(:title => "something")
|
10
|
-
UniformNotifier::Base.inline_notify("something")
|
6
|
+
context '#inline_channel_notify' do
|
7
|
+
before { allow(UniformNotifier::Base).to receive(:active?).and_return(true) }
|
8
|
+
it 'should keep the compatibility' do
|
9
|
+
expect(UniformNotifier::Base).to receive(:_inline_notify).once.with(title: 'something')
|
10
|
+
UniformNotifier::Base.inline_notify('something')
|
11
11
|
end
|
12
12
|
end
|
13
|
-
context
|
14
|
-
before
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
expect(UniformNotifier::Base).to receive(:_out_of_channel_notify).once.with(:title => "something")
|
19
|
-
UniformNotifier::Base.out_of_channel_notify("something")
|
13
|
+
context '#out_of_channel_notify' do
|
14
|
+
before { allow(UniformNotifier::Base).to receive(:active?).and_return(true) }
|
15
|
+
it 'should keep the compatibility' do
|
16
|
+
expect(UniformNotifier::Base).to receive(:_out_of_channel_notify).once.with(title: 'something')
|
17
|
+
UniformNotifier::Base.out_of_channel_notify('something')
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
2
4
|
|
3
5
|
class Bugsnag
|
4
6
|
# mock Bugsnag
|
@@ -6,51 +8,63 @@ end
|
|
6
8
|
|
7
9
|
RSpec.describe UniformNotifier::BugsnagNotifier do
|
8
10
|
let(:notification_data) { {} }
|
9
|
-
it
|
11
|
+
it 'should not notify bugsnag' do
|
10
12
|
expect(Bugsnag).not_to receive(:notify)
|
11
13
|
UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
|
12
14
|
end
|
13
|
-
context
|
14
|
-
let(:notification_data) { {:
|
15
|
+
context 'with string notification' do
|
16
|
+
let(:notification_data) { { user: 'user', title: 'notify bugsnag', url: 'URL', body: 'something' } }
|
15
17
|
|
16
|
-
it
|
17
|
-
expect(Bugsnag).to receive(:notify).with(
|
18
|
+
it 'should notify bugsnag' do
|
19
|
+
expect(Bugsnag).to receive(:notify).with(
|
20
|
+
UniformNotifier::Exception.new(notification_data[:title]),
|
21
|
+
grouping_hash: notification_data[:body], notification: notification_data
|
22
|
+
)
|
18
23
|
|
19
24
|
UniformNotifier.bugsnag = true
|
20
25
|
UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
|
21
26
|
end
|
22
27
|
|
23
|
-
it
|
24
|
-
expect(Bugsnag).to receive(:notify).with(
|
28
|
+
it 'should notify bugsnag with option' do
|
29
|
+
expect(Bugsnag).to receive(:notify).with(
|
30
|
+
UniformNotifier::Exception.new(notification_data[:title]),
|
31
|
+
foo: :bar, grouping_hash: notification_data[:body], notification: notification_data
|
32
|
+
)
|
25
33
|
|
26
|
-
UniformNotifier.bugsnag = { :
|
34
|
+
UniformNotifier.bugsnag = { foo: :bar }
|
27
35
|
UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
|
28
36
|
end
|
29
37
|
end
|
30
|
-
context
|
31
|
-
let(:notification_data) {
|
38
|
+
context 'with hash notification' do
|
39
|
+
let(:notification_data) { 'notify bugsnag' }
|
32
40
|
|
33
|
-
it
|
34
|
-
expect(Bugsnag).to receive(:notify).with(
|
41
|
+
it 'should notify bugsnag' do
|
42
|
+
expect(Bugsnag).to receive(:notify).with(
|
43
|
+
UniformNotifier::Exception.new('notify bugsnag'),
|
44
|
+
grouping_hash: 'notify bugsnag', notification: { title: 'notify bugsnag' }
|
45
|
+
)
|
35
46
|
|
36
47
|
UniformNotifier.bugsnag = true
|
37
48
|
UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
|
38
49
|
end
|
39
50
|
|
40
|
-
it
|
41
|
-
expect(Bugsnag).to receive(:notify).with(
|
51
|
+
it 'should notify bugsnag with option' do
|
52
|
+
expect(Bugsnag).to receive(:notify).with(
|
53
|
+
UniformNotifier::Exception.new('notify bugsnag'),
|
54
|
+
foo: :bar, grouping_hash: 'notify bugsnag', notification: { title: 'notify bugsnag' }
|
55
|
+
)
|
42
56
|
|
43
|
-
UniformNotifier.bugsnag = { :
|
57
|
+
UniformNotifier.bugsnag = { foo: :bar }
|
44
58
|
UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
|
45
59
|
end
|
46
60
|
end
|
47
61
|
|
48
|
-
it
|
62
|
+
it 'should notify bugsnag with correct backtrace' do
|
49
63
|
expect(Bugsnag).to receive(:notify) do |error|
|
50
64
|
expect(error).to be_a UniformNotifier::Exception
|
51
|
-
expect(error.backtrace).to eq [
|
65
|
+
expect(error.backtrace).to eq ['bugsnag spec test']
|
52
66
|
end
|
53
67
|
UniformNotifier.bugsnag = true
|
54
|
-
UniformNotifier::BugsnagNotifier.out_of_channel_notify(backtrace: [
|
68
|
+
UniformNotifier::BugsnagNotifier.out_of_channel_notify(backtrace: ['bugsnag spec test'])
|
55
69
|
end
|
56
70
|
end
|
@@ -1,21 +1,23 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
2
4
|
|
3
5
|
RSpec.describe UniformNotifier::CustomizedLogger do
|
4
|
-
it
|
5
|
-
expect(UniformNotifier::CustomizedLogger.out_of_channel_notify(:
|
6
|
+
it 'should not notify to customized logger' do
|
7
|
+
expect(UniformNotifier::CustomizedLogger.out_of_channel_notify(title: 'notify rails logger')).to be_nil
|
6
8
|
end
|
7
9
|
|
8
|
-
it
|
9
|
-
logger = File.open(
|
10
|
+
it 'should notify to customized logger' do
|
11
|
+
logger = File.open('test.log', 'a+')
|
10
12
|
logger.sync = true
|
11
13
|
|
12
14
|
now = Time.now
|
13
15
|
allow(Time).to receive(:now).and_return(now)
|
14
16
|
UniformNotifier.customized_logger = logger
|
15
|
-
UniformNotifier::CustomizedLogger.out_of_channel_notify(:
|
17
|
+
UniformNotifier::CustomizedLogger.out_of_channel_notify(title: 'notify rails logger')
|
16
18
|
|
17
19
|
logger.seek(0)
|
18
|
-
expect(logger.read).to eq "#{now.strftime(
|
20
|
+
expect(logger.read).to eq "#{now.strftime('%Y-%m-%d %H:%M:%S')}[WARN] notify rails logger"
|
19
21
|
|
20
22
|
File.delete('test.log')
|
21
23
|
end
|
@@ -1,56 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
RSpec.describe UniformNotifier::Growl do
|
4
|
-
|
5
|
-
|
6
|
-
expect(UniformNotifier::Growl.out_of_channel_notify(:title => 'notify growl')).to be_nil
|
6
|
+
it 'should not notify growl' do
|
7
|
+
expect(UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl')).to be_nil
|
7
8
|
end
|
8
9
|
|
9
|
-
it
|
10
|
-
growl = double('growl',
|
10
|
+
it 'should notify growl without password' do
|
11
|
+
growl = double('growl', is_a?: true)
|
11
12
|
expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
|
12
13
|
expect(growl).to receive(:add_notification).with('uniform_notifier')
|
13
14
|
expect(growl).to receive(:password=).with(nil)
|
14
|
-
expect(growl).to receive(:notify).with(
|
15
|
-
|
15
|
+
expect(growl).to receive(:notify).with(
|
16
|
+
'uniform_notifier',
|
17
|
+
'Uniform Notifier',
|
18
|
+
'Uniform Notifier Growl has been turned on'
|
19
|
+
).ordered
|
20
|
+
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl without password')
|
21
|
+
.ordered
|
16
22
|
|
17
23
|
UniformNotifier.growl = true
|
18
|
-
UniformNotifier::Growl.out_of_channel_notify(:
|
24
|
+
UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl without password')
|
19
25
|
end
|
20
26
|
|
21
|
-
it
|
22
|
-
growl = double('growl',
|
27
|
+
it 'should notify growl with password' do
|
28
|
+
growl = double('growl', is_a?: true)
|
23
29
|
expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
|
24
30
|
expect(growl).to receive(:add_notification).with('uniform_notifier')
|
25
31
|
expect(growl).to receive(:password=).with('123456')
|
26
|
-
expect(growl).to receive(:notify).with(
|
32
|
+
expect(growl).to receive(:notify).with(
|
33
|
+
'uniform_notifier',
|
34
|
+
'Uniform Notifier',
|
35
|
+
'Uniform Notifier Growl has been turned on'
|
36
|
+
).ordered
|
27
37
|
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
|
28
38
|
|
29
|
-
UniformNotifier.growl = { :
|
30
|
-
UniformNotifier::Growl.out_of_channel_notify(:
|
39
|
+
UniformNotifier.growl = { password: '123456' }
|
40
|
+
UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl with password')
|
31
41
|
end
|
32
42
|
|
33
|
-
it
|
34
|
-
growl = double('growl',
|
43
|
+
it 'should notify growl with host' do
|
44
|
+
growl = double('growl', is_a?: true)
|
35
45
|
expect(Growl).to receive(:new).with('10.10.156.17', 'uniform_notifier').and_return(growl)
|
36
46
|
expect(growl).to receive(:add_notification).with('uniform_notifier')
|
37
47
|
expect(growl).to receive(:password=).with('123456')
|
38
|
-
expect(growl).to receive(:notify).with(
|
48
|
+
expect(growl).to receive(:notify).with(
|
49
|
+
'uniform_notifier',
|
50
|
+
'Uniform Notifier',
|
51
|
+
'Uniform Notifier Growl has been turned on'
|
52
|
+
).ordered
|
39
53
|
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
|
40
54
|
|
41
|
-
UniformNotifier.growl = { :
|
42
|
-
UniformNotifier::Growl.out_of_channel_notify(:
|
55
|
+
UniformNotifier.growl = { password: '123456', host: '10.10.156.17' }
|
56
|
+
UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl with password')
|
43
57
|
end
|
44
58
|
|
45
|
-
it
|
46
|
-
growl = double('growl',
|
59
|
+
it 'should notify growl with quiet' do
|
60
|
+
growl = double('growl', is_a?: true)
|
47
61
|
expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
|
48
62
|
expect(growl).to receive(:add_notification).with('uniform_notifier')
|
49
63
|
expect(growl).to receive(:password=).with('123456')
|
50
|
-
expect(growl).not_to receive(:notify).with(
|
64
|
+
expect(growl).not_to receive(:notify).with(
|
65
|
+
'uniform_notifier',
|
66
|
+
'Uniform Notifier',
|
67
|
+
'Uniform Notifier Growl has been turned on'
|
68
|
+
)
|
51
69
|
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password')
|
52
70
|
|
53
|
-
UniformNotifier.growl = { :
|
54
|
-
UniformNotifier::Growl.out_of_channel_notify(:
|
71
|
+
UniformNotifier.growl = { password: '123456', quiet: true }
|
72
|
+
UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl with password')
|
55
73
|
end
|
56
74
|
end
|
@@ -1,25 +1,27 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
2
4
|
|
3
5
|
class Honeybadger
|
4
6
|
# mock Honeybadger
|
5
7
|
end
|
6
8
|
|
7
9
|
RSpec.describe UniformNotifier::HoneybadgerNotifier do
|
8
|
-
it
|
9
|
-
expect(UniformNotifier::HoneybadgerNotifier.out_of_channel_notify(:
|
10
|
+
it 'should not notify honeybadger' do
|
11
|
+
expect(UniformNotifier::HoneybadgerNotifier.out_of_channel_notify(title: 'notify honeybadger')).to be_nil
|
10
12
|
end
|
11
13
|
|
12
|
-
it
|
13
|
-
expect(Honeybadger).to receive(:notify).with(UniformNotifier::Exception.new(
|
14
|
+
it 'should notify honeybadger' do
|
15
|
+
expect(Honeybadger).to receive(:notify).with(UniformNotifier::Exception.new('notify honeybadger'), {})
|
14
16
|
|
15
17
|
UniformNotifier.honeybadger = true
|
16
|
-
UniformNotifier::HoneybadgerNotifier.out_of_channel_notify(:
|
18
|
+
UniformNotifier::HoneybadgerNotifier.out_of_channel_notify(title: 'notify honeybadger')
|
17
19
|
end
|
18
20
|
|
19
|
-
it
|
20
|
-
expect(Honeybadger).to receive(:notify).with(UniformNotifier::Exception.new(
|
21
|
+
it 'should notify honeybadger' do
|
22
|
+
expect(Honeybadger).to receive(:notify).with(UniformNotifier::Exception.new('notify honeybadger'), foo: :bar)
|
21
23
|
|
22
|
-
UniformNotifier.honeybadger = { :
|
23
|
-
UniformNotifier::HoneybadgerNotifier.out_of_channel_notify(
|
24
|
+
UniformNotifier.honeybadger = { foo: :bar }
|
25
|
+
UniformNotifier::HoneybadgerNotifier.out_of_channel_notify('notify honeybadger')
|
24
26
|
end
|
25
27
|
end
|
@@ -1,16 +1,36 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
2
4
|
|
3
5
|
RSpec.describe UniformNotifier::JavascriptAlert do
|
4
|
-
it
|
5
|
-
expect(UniformNotifier::JavascriptAlert.inline_notify(:
|
6
|
+
it 'should not notify message' do
|
7
|
+
expect(UniformNotifier::JavascriptAlert.inline_notify(title: 'javascript alert!')).to be_nil
|
6
8
|
end
|
7
9
|
|
8
|
-
it
|
10
|
+
it 'should notify message' do
|
9
11
|
UniformNotifier.alert = true
|
10
|
-
expect(UniformNotifier::JavascriptAlert.inline_notify(:
|
11
|
-
<script type="text/javascript">/*<![CDATA[*/
|
12
|
-
alert( "javascript alert!" );
|
13
|
-
/*]]>*/</script>
|
14
|
-
CODE
|
12
|
+
expect(UniformNotifier::JavascriptAlert.inline_notify(title: 'javascript alert!')).to eq <<~CODE
|
13
|
+
<script type="text/javascript">/*<![CDATA[*/
|
14
|
+
alert( "javascript alert!" );
|
15
|
+
/*]]>*/</script>
|
16
|
+
CODE
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should accept custom attributes' do
|
20
|
+
UniformNotifier.alert = { attributes: { nonce: 'my-nonce', 'data-key' => :value } }
|
21
|
+
expect(UniformNotifier::JavascriptAlert.inline_notify(title: 'javascript alert!')).to eq <<~CODE
|
22
|
+
<script type="text/javascript" nonce="my-nonce" data-key="value">/*<![CDATA[*/
|
23
|
+
alert( "javascript alert!" );
|
24
|
+
/*]]>*/</script>
|
25
|
+
CODE
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should have default attributes if no attributes settings exist' do
|
29
|
+
UniformNotifier.alert = {}
|
30
|
+
expect(UniformNotifier::JavascriptAlert.inline_notify(title: 'javascript alert!')).to eq <<~CODE
|
31
|
+
<script type="text/javascript">/*<![CDATA[*/
|
32
|
+
alert( "javascript alert!" );
|
33
|
+
/*]]>*/</script>
|
34
|
+
CODE
|
15
35
|
end
|
16
36
|
end
|
@@ -1,25 +1,63 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
2
4
|
|
3
5
|
RSpec.describe UniformNotifier::JavascriptConsole do
|
4
|
-
it
|
5
|
-
expect(UniformNotifier::JavascriptConsole.inline_notify(:
|
6
|
+
it 'should not notify message' do
|
7
|
+
expect(UniformNotifier::JavascriptConsole.inline_notify(title: 'javascript console!')).to be_nil
|
6
8
|
end
|
7
9
|
|
8
|
-
it
|
10
|
+
it 'should notify message' do
|
9
11
|
UniformNotifier.console = true
|
10
|
-
expect(UniformNotifier::JavascriptConsole.inline_notify(:
|
11
|
-
<script type="text/javascript">/*<![CDATA[*/
|
12
|
-
if (typeof(console) !== 'undefined' && console.log) {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
21
|
-
|
22
|
-
/*]]>*/</script>
|
12
|
+
expect(UniformNotifier::JavascriptConsole.inline_notify(title: 'javascript console!')).to eq <<~CODE
|
13
|
+
<script type="text/javascript">/*<![CDATA[*/
|
14
|
+
if (typeof(console) !== 'undefined' && console.log) {
|
15
|
+
if (console.groupCollapsed && console.groupEnd) {
|
16
|
+
console.groupCollapsed(#{'Uniform Notifier'.inspect});
|
17
|
+
console.log(#{'javascript console!'.inspect});
|
18
|
+
console.groupEnd();
|
19
|
+
} else {
|
20
|
+
console.log(#{'javascript console!'.inspect});
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
/*]]>*/</script>
|
25
|
+
CODE
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should accept custom attributes' do
|
29
|
+
UniformNotifier.console = { attributes: { nonce: 'my-nonce', 'data-key' => :value } }
|
30
|
+
expect(UniformNotifier::JavascriptConsole.inline_notify(title: 'javascript console!')).to eq <<~CODE
|
31
|
+
<script type="text/javascript" nonce="my-nonce" data-key="value">/*<![CDATA[*/
|
32
|
+
if (typeof(console) !== 'undefined' && console.log) {
|
33
|
+
if (console.groupCollapsed && console.groupEnd) {
|
34
|
+
console.groupCollapsed(#{'Uniform Notifier'.inspect});
|
35
|
+
console.log(#{'javascript console!'.inspect});
|
36
|
+
console.groupEnd();
|
37
|
+
} else {
|
38
|
+
console.log(#{'javascript console!'.inspect});
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
/*]]>*/</script>
|
43
|
+
CODE
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should have default attributes if no attributes settings exist' do
|
47
|
+
UniformNotifier.console = {}
|
48
|
+
expect(UniformNotifier::JavascriptConsole.inline_notify(title: 'javascript console!')).to eq <<~CODE
|
49
|
+
<script type="text/javascript">/*<![CDATA[*/
|
50
|
+
if (typeof(console) !== 'undefined' && console.log) {
|
51
|
+
if (console.groupCollapsed && console.groupEnd) {
|
52
|
+
console.groupCollapsed(#{'Uniform Notifier'.inspect});
|
53
|
+
console.log(#{'javascript console!'.inspect});
|
54
|
+
console.groupEnd();
|
55
|
+
} else {
|
56
|
+
console.log(#{'javascript console!'.inspect});
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
/*]]>*/</script>
|
23
61
|
CODE
|
24
62
|
end
|
25
63
|
end
|