notifly 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. metadata +1 -69
  3. data/.editorconfig +0 -22
  4. data/.rspec +0 -2
  5. data/.travis.yml +0 -13
  6. data/Gemfile +0 -24
  7. data/Gemfile.lock +0 -199
  8. data/VERSION +0 -1
  9. data/app/assets/images/notifly/.keep +0 -0
  10. data/spec/controllers/notifly/notifications_controller_spec.rb +0 -44
  11. data/spec/dummy/README.rdoc +0 -28
  12. data/spec/dummy/Rakefile +0 -6
  13. data/spec/dummy/app/assets/images/.keep +0 -0
  14. data/spec/dummy/app/assets/javascripts/application.js +0 -14
  15. data/spec/dummy/app/assets/stylesheets/application.css +0 -20
  16. data/spec/dummy/app/controllers/application_controller.rb +0 -13
  17. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  18. data/spec/dummy/app/controllers/site_controller.rb +0 -4
  19. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  20. data/spec/dummy/app/mailers/.keep +0 -0
  21. data/spec/dummy/app/models/.keep +0 -0
  22. data/spec/dummy/app/models/concerns/.keep +0 -0
  23. data/spec/dummy/app/models/dummy_object.rb +0 -19
  24. data/spec/dummy/app/models/post.rb +0 -21
  25. data/spec/dummy/app/views/layouts/application.html.erb +0 -15
  26. data/spec/dummy/app/views/site/index.html.erb +0 -2
  27. data/spec/dummy/bin/bundle +0 -3
  28. data/spec/dummy/bin/rails +0 -4
  29. data/spec/dummy/bin/rake +0 -4
  30. data/spec/dummy/config.ru +0 -4
  31. data/spec/dummy/config/application.rb +0 -29
  32. data/spec/dummy/config/boot.rb +0 -5
  33. data/spec/dummy/config/database.exemple.yml +0 -12
  34. data/spec/dummy/config/database.travis.yml +0 -4
  35. data/spec/dummy/config/environment.rb +0 -5
  36. data/spec/dummy/config/environments/development.rb +0 -37
  37. data/spec/dummy/config/environments/production.rb +0 -78
  38. data/spec/dummy/config/environments/test.rb +0 -39
  39. data/spec/dummy/config/initializers/assets.rb +0 -8
  40. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  41. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  42. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  43. data/spec/dummy/config/initializers/inflections.rb +0 -16
  44. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  45. data/spec/dummy/config/initializers/session_store.rb +0 -3
  46. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  47. data/spec/dummy/config/locales/en.yml +0 -23
  48. data/spec/dummy/config/routes.rb +0 -5
  49. data/spec/dummy/config/secrets.yml +0 -22
  50. data/spec/dummy/db/migrate/20141031165049_create_dummy_objects.rb +0 -9
  51. data/spec/dummy/db/migrate/20141103191353_create_posts.rb +0 -10
  52. data/spec/dummy/db/migrate/20141104121318_add_dummy_to_post.rb +0 -5
  53. data/spec/dummy/db/schema.rb +0 -54
  54. data/spec/dummy/lib/assets/.keep +0 -0
  55. data/spec/dummy/log/.keep +0 -0
  56. data/spec/dummy/public/404.html +0 -67
  57. data/spec/dummy/public/422.html +0 -67
  58. data/spec/dummy/public/500.html +0 -66
  59. data/spec/dummy/public/favicon.ico +0 -0
  60. data/spec/dummy/spec/features/notifly/counter_spec.rb +0 -38
  61. data/spec/dummy/spec/features/notifly/loading_notifications_spec.rb +0 -38
  62. data/spec/dummy/spec/features/notifly/read_notifications_spec.rb +0 -70
  63. data/spec/dummy/spec/models/dummy_object_spec.rb +0 -58
  64. data/spec/dummy/spec/models/post_spec.rb +0 -89
  65. data/spec/models/notifly/notification_spec.rb +0 -18
  66. data/spec/rails_helper.rb +0 -21
  67. data/spec/spec_helper.rb +0 -62
  68. data/spec/support/shared_connection.rb +0 -14
  69. data/spec/support/suppress_log.rb +0 -3
  70. data/spec/support/wait_ajax.rb +0 -53
@@ -1,58 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe DummyObject, :type => :model do
4
- it { is_expected.to have_many(:posts) }
5
-
6
- describe 'Notifly' do
7
- let(:smart) { DummyObject.create name: 'smart' }
8
- let(:dummy) { DummyObject.create name: nil }
9
- let(:notifications) { Notifly::Notification }
10
-
11
- it 'should return the method return' do
12
- expect(smart.buzz).to eql('buzz')
13
- expect(dummy.buzz).to eql('buzz')
14
-
15
- expect(smart.update(name: 'smart')).to be_truthy
16
- expect(dummy.update(name: 'dummy')).to be_truthy
17
- end
18
-
19
- context 'when using ActiveRecord methods' do
20
- describe 'class methods' do
21
- describe '.create' do
22
- it { expect { DummyObject.create name: 'dummy' }.
23
- to_not change(notifications.where(template: :create), :count) }
24
- it { expect { DummyObject.create name: 'smart' }.
25
- to change(notifications.where(template: :create), :count).from(0).to(1) }
26
- end
27
- end
28
-
29
- describe 'instance methods' do
30
- before(:each) do
31
- smart
32
- dummy
33
- notifications.delete_all
34
- end
35
-
36
- describe '#save' do
37
- it { expect { smart.save! }.to change(notifications.
38
- where(template: :save), :count).from(0).to(1) }
39
- it { expect { dummy.save! }.to_not change(notifications.
40
- where(template: :save), :count) }
41
- end
42
-
43
- describe '#update' do
44
- it { expect { dummy.update!(name: 'smart') }.to change(notifications.
45
- where(template: :update), :count).from(0).to(1) }
46
- it { expect { smart.update!(name: 'dummy') }.to_not change(notifications.
47
- where(template: :update), :count) }
48
- end
49
-
50
- describe '#destroy' do
51
- it { expect { smart.destroy! }.to change(notifications, :count).
52
- from(0).to(1) }
53
- it { expect { dummy.destroy! }.to_not change(notifications, :count) }
54
- end
55
- end
56
- end
57
- end
58
- end
@@ -1,89 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe Post, :type => :model do
4
- it { is_expected.to belong_to(:dummy_object) }
5
-
6
- describe 'Notifly' do
7
- let(:dummy) { DummyObject.create! }
8
- let(:post) { Post.create! dummy_object: dummy, published: false }
9
- let(:notification) { Notifly::Notification.take }
10
-
11
- describe 'initialization' do
12
- it { expect(Post).to respond_to :notifly }
13
- end
14
-
15
- describe 'usage' do
16
- it 'should create a notification when is published' do
17
- expect(Notifly::Notification.count).to eql 0
18
-
19
- expect { post.publish! }.to change(Notifly::Notification, :count).from(0).to(1)
20
- expect(notification.receiver).to eql dummy
21
- expect(notification.target).to eql post
22
- expect(notification.template).to eql 'publish'
23
- end
24
-
25
- describe 'Notification fallback (data)' do
26
- it 'should use Notifly::Notification#data for missing informations' do
27
- post_attributes = post.attributes
28
- expect { post.destroy }.to change(Notifly::Notification, :count).from(0).to(1)
29
-
30
- expect(notification.receiver).to eql dummy
31
- expect(notification.template).to eql 'destroy'
32
- expect(notification.reload.data).to eql post_attributes
33
- end
34
- end
35
-
36
- context 'when run notifly by order' do
37
- context 'when post title starts with nil' do
38
- it 'should send two notifications' do
39
- expect { post.change_title }.to change(Notifly::Notification, :count).
40
- from(0).to(2)
41
-
42
- expect(Notifly::Notification.first.data['title']).to be_nil
43
- expect(Notifly::Notification.last.data['title']).to eql 'NewTitle'
44
- end
45
- end
46
-
47
- context 'when post title starts with TitleFoo' do
48
- it 'should send two notifications' do
49
- expect_any_instance_of(Post).to receive(:change_title) { nil }
50
- post = Post.create! dummy_object: dummy, title: 'TitleFoo'
51
-
52
- expect { post.change_title }.to_not change(Notifly::Notification, :count)
53
- end
54
- end
55
- end
56
- end
57
-
58
- describe '#notifly_notifications' do
59
- it 'should show its notifications' do
60
- dummy_notification = Notifly::Notification.create! receiver: dummy,
61
- sender: post
62
- post_notifications = (1..3).map do
63
- Notifly::Notification.create! receiver: post, sender: dummy
64
- end
65
-
66
- expect(post.notifly_notifications).to include(*post_notifications)
67
- expect(post.notifly_notifications).to_not include(dummy_notification)
68
- end
69
-
70
- it 'should query its notifications' do
71
- dummy_2 = DummyObject.create
72
- notification_1 = Notifly::Notification.create! receiver: post,
73
- sender: dummy, template: 'destroy'
74
- notification_2 = Notifly::Notification.create! receiver: post,
75
- sender: dummy, target: dummy_2
76
- notification_3 = Notifly::Notification.create! receiver: post,
77
- sender: dummy, target: dummy_2
78
-
79
- destroy_notifications = post.notifly_notifications.where(template: 'destroy')
80
- dummy_2_notifications = post.notifly_notifications.where(target: dummy_2)
81
-
82
- expect(destroy_notifications).to include(notification_1)
83
- expect(destroy_notifications).to_not include(notification_2, notification_3)
84
- expect(dummy_2_notifications).to include(notification_2, notification_3)
85
- expect(dummy_2_notifications).to_not include(notification_1)
86
- end
87
- end
88
- end
89
- end
@@ -1,18 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module Notifly
4
- RSpec.describe Notification, :type => :model do
5
- it { is_expected.to validate_presence_of(:receiver) }
6
-
7
- describe '#data' do
8
- it 'should save and repond with a hash' do
9
- hash = { 'post' => Post.create!.attributes }
10
-
11
- notification = Notifly::Notification.create! receiver: DummyObject.create,
12
- template: :foo, data: hash
13
-
14
- expect(notification.reload.data).to eql hash
15
- end
16
- end
17
- end
18
- end
@@ -1,21 +0,0 @@
1
- # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- ENV["RAILS_ENV"] ||= 'test'
3
- require 'spec_helper'
4
- require File.expand_path("../dummy/config/environment", __FILE__)
5
- require 'rspec/rails'
6
- require 'shoulda/matchers'
7
- require 'capybara/rails'
8
- require 'capybara/rspec'
9
- require 'capybara/poltergeist'
10
- Capybara.javascript_driver = :poltergeist
11
-
12
- Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f }
13
-
14
- # Checks for pending migrations before tests are run.
15
- ActiveRecord::Migration.maintain_test_schema!
16
-
17
- RSpec.configure do |config|
18
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
19
- config.use_transactional_fixtures = true
20
- config.infer_spec_type_from_file_location!
21
- end
@@ -1,62 +0,0 @@
1
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
2
-
3
- RSpec.configure do |config|
4
- if config.files_to_run.one?
5
- config.default_formatter = 'doc'
6
- end
7
-
8
- config.expect_with :rspec do |expectations|
9
- expectations.syntax = :expect
10
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
11
- end
12
-
13
- config.mock_with :rspec do |mocks|
14
- mocks.syntax = :expect
15
- mocks.verify_partial_doubles = true
16
- end
17
-
18
- # The settings below are suggested to provide a good initial experience
19
- # with RSpec, but feel free to customize to your heart's content.
20
- =begin
21
- # These two settings work together to allow you to limit a spec run
22
- # to individual examples or groups you care about by tagging them with
23
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
24
- # get run.
25
- config.filter_run :focus
26
- config.run_all_when_everything_filtered = true
27
-
28
- # Limits the available syntax to the non-monkey patched syntax that is recommended.
29
- # For more details, see:
30
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
31
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
32
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
33
- config.disable_monkey_patching!
34
-
35
- # Many RSpec users commonly either run the entire suite or an individual
36
- # file, and it's useful to allow more verbose output when running an
37
- # individual spec file.
38
- if config.files_to_run.one?
39
- # Use the documentation formatter for detailed output,
40
- # unless a formatter has already been configured
41
- # (e.g. via a command-line flag).
42
- config.default_formatter = 'doc'
43
- end
44
-
45
- # Print the 10 slowest examples and example groups at the
46
- # end of the spec run, to help surface which specs are running
47
- # particularly slow.
48
- config.profile_examples = 10
49
-
50
- # Run specs in random order to surface order dependencies. If you find an
51
- # order dependency and want to debug it, you can fix the order by providing
52
- # the seed, which is printed after each run.
53
- # --seed 1234
54
- config.order = :random
55
-
56
- # Seed global randomization in this process using the `--seed` CLI option.
57
- # Setting this allows you to use `--seed` to deterministically reproduce
58
- # test failures related to randomization by passing the same `--seed` value
59
- # as the one that triggered the failure.
60
- Kernel.srand config.seed
61
- =end
62
- end
@@ -1,14 +0,0 @@
1
- # http://helabs.com.br/blog/2013/02/06/testes-mais-rapidos-no-rspec
2
-
3
- class ActiveRecord::Base
4
- mattr_accessor :shared_connection
5
- @@shared_connection = nil
6
-
7
- def self.connection
8
- @@shared_connection || retrieve_connection
9
- end
10
- end
11
-
12
- # Forces all threads to share the same connection. This works on
13
- # Capybara because it starts the web server in a thread.
14
- ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
@@ -1,3 +0,0 @@
1
- # http://helabs.com.br/blog/2013/02/06/testes-mais-rapidos-no-rspec
2
-
3
- Rails.logger.level = 4 unless ENV['WITH_LOG']
@@ -1,53 +0,0 @@
1
- # Ajax testing with ruby and capybara
2
- #
3
- # Add this to spec/support
4
- #
5
- # When a link or button starts an ajax request, instead of use Capybara
6
- # click_link, click_button and click_link_or_button methods use click_ajax_link,
7
- # click_ajax_button and click_ajax_link_or_button methods. You can still use
8
- # capybara methods and right after it, call wait_for_ajax method.
9
- #
10
- # This methods will wait until Capybara.default_wait_time for the ajax request
11
- # to finish before continue the normal tests flow.
12
- #
13
-
14
- require 'timeout'
15
-
16
- module WaitForAjax
17
- def click_ajax_link(locator, options = {})
18
- click_link(locator, options)
19
-
20
- wait_for_ajax
21
- end
22
-
23
- def click_ajax_button(locator, options = {})
24
- click_button(locator, options)
25
-
26
- wait_for_ajax
27
- end
28
-
29
- def click_ajax_link_or_button(locator, options = {})
30
- click_link_or_button(locator, options)
31
-
32
- wait_for_ajax
33
- end
34
-
35
- def wait_for_ajax(&block)
36
- block.call if block
37
-
38
- Timeout.timeout(Capybara.default_wait_time) do
39
- loop do
40
- sleep 0.1
41
- break if finished_all_ajax_requests?
42
- end
43
- end
44
- end
45
-
46
- def finished_all_ajax_requests?
47
- page.evaluate_script('jQuery.active').zero?
48
- end
49
- end
50
-
51
- RSpec.configure do |config|
52
- config.include WaitForAjax
53
- end