forked from simukappu/activity_notification
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
1,387 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
service_name: travis-ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--color | ||
--require spec_helper | ||
--format documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
language: ruby | ||
|
||
rvm: | ||
- 2.1.9 | ||
- 2.2.5 | ||
- 2.3.1 | ||
- ruby-head | ||
|
||
gemfile: | ||
- Gemfile | ||
|
||
matrix: | ||
allow_failures: | ||
- rvm: ruby-head | ||
fast_finish: true | ||
|
||
sudo: false | ||
|
||
cache: bundler | ||
|
||
before_install: "rm ${BUNDLE_GEMFILE}.lock" | ||
|
||
before_script: "bundle update" | ||
|
||
script: bundle exec rspec | ||
|
||
notifications: | ||
email: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Declare your gem's dependencies in activity_notification.gemspec. | ||
# Bundler will treat runtime dependencies like base dependencies, and | ||
# development dependencies will be added by default to the :development group. | ||
gemspec | ||
|
||
# Declare any dependencies that are still in development here instead of in | ||
# your gemspec. These might include edge Rails or gems from your path or | ||
# Git. Remember to move these dependencies to your gemspec before releasing | ||
# your gem to rubygems.org. | ||
|
||
# To use a debugger | ||
# gem 'byebug', group: [:development, :test] | ||
|
||
gem 'coveralls', require: false, group: :test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
activity_notification (0.0.2) | ||
activerecord (>= 3.0) | ||
rails (~> 4.2.5) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
actionmailer (4.2.7) | ||
actionpack (= 4.2.7) | ||
actionview (= 4.2.7) | ||
activejob (= 4.2.7) | ||
mail (~> 2.5, >= 2.5.4) | ||
rails-dom-testing (~> 1.0, >= 1.0.5) | ||
actionpack (4.2.7) | ||
actionview (= 4.2.7) | ||
activesupport (= 4.2.7) | ||
rack (~> 1.6) | ||
rack-test (~> 0.6.2) | ||
rails-dom-testing (~> 1.0, >= 1.0.5) | ||
rails-html-sanitizer (~> 1.0, >= 1.0.2) | ||
actionview (4.2.7) | ||
activesupport (= 4.2.7) | ||
builder (~> 3.1) | ||
erubis (~> 2.7.0) | ||
rails-dom-testing (~> 1.0, >= 1.0.5) | ||
rails-html-sanitizer (~> 1.0, >= 1.0.2) | ||
activejob (4.2.7) | ||
activesupport (= 4.2.7) | ||
globalid (>= 0.3.0) | ||
activemodel (4.2.7) | ||
activesupport (= 4.2.7) | ||
builder (~> 3.1) | ||
activerecord (4.2.7) | ||
activemodel (= 4.2.7) | ||
activesupport (= 4.2.7) | ||
arel (~> 6.0) | ||
activesupport (4.2.7) | ||
i18n (~> 0.7) | ||
json (~> 1.7, >= 1.7.7) | ||
minitest (~> 5.1) | ||
thread_safe (~> 0.3, >= 0.3.4) | ||
tzinfo (~> 1.1) | ||
arel (6.0.3) | ||
bcrypt (3.1.11) | ||
builder (3.2.2) | ||
concurrent-ruby (1.0.2) | ||
coveralls (0.8.14) | ||
json (>= 1.8, < 3) | ||
simplecov (~> 0.12.0) | ||
term-ansicolor (~> 1.3) | ||
thor (~> 0.19.1) | ||
tins (~> 1.6.0) | ||
devise (4.2.0) | ||
bcrypt (~> 3.0) | ||
orm_adapter (~> 0.1) | ||
railties (>= 4.1.0, < 5.1) | ||
responders | ||
warden (~> 1.2.3) | ||
diff-lcs (1.2.5) | ||
docile (1.1.5) | ||
erubis (2.7.0) | ||
factory_girl (4.7.0) | ||
activesupport (>= 3.0.0) | ||
factory_girl_rails (4.7.0) | ||
factory_girl (~> 4.7.0) | ||
railties (>= 3.0.0) | ||
globalid (0.3.6) | ||
activesupport (>= 4.1.0) | ||
i18n (0.7.0) | ||
json (1.8.3) | ||
loofah (2.0.3) | ||
nokogiri (>= 1.5.9) | ||
mail (2.6.4) | ||
mime-types (>= 1.16, < 4) | ||
mime-types (3.1) | ||
mime-types-data (~> 3.2015) | ||
mime-types-data (3.2016.0521) | ||
mini_portile2 (2.1.0) | ||
minitest (5.9.0) | ||
nokogiri (1.6.8) | ||
mini_portile2 (~> 2.1.0) | ||
pkg-config (~> 1.1.7) | ||
orm_adapter (0.5.0) | ||
pkg-config (1.1.7) | ||
rack (1.6.4) | ||
rack-test (0.6.3) | ||
rack (>= 1.0) | ||
rails (4.2.7) | ||
actionmailer (= 4.2.7) | ||
actionpack (= 4.2.7) | ||
actionview (= 4.2.7) | ||
activejob (= 4.2.7) | ||
activemodel (= 4.2.7) | ||
activerecord (= 4.2.7) | ||
activesupport (= 4.2.7) | ||
bundler (>= 1.3.0, < 2.0) | ||
railties (= 4.2.7) | ||
sprockets-rails | ||
rails-deprecated_sanitizer (1.0.3) | ||
activesupport (>= 4.2.0.alpha) | ||
rails-dom-testing (1.0.7) | ||
activesupport (>= 4.2.0.beta, < 5.0) | ||
nokogiri (~> 1.6.0) | ||
rails-deprecated_sanitizer (>= 1.0.1) | ||
rails-html-sanitizer (1.0.3) | ||
loofah (~> 2.0) | ||
railties (4.2.7) | ||
actionpack (= 4.2.7) | ||
activesupport (= 4.2.7) | ||
rake (>= 0.8.7) | ||
thor (>= 0.18.1, < 2.0) | ||
rake (11.2.2) | ||
responders (2.2.0) | ||
railties (>= 4.2.0, < 5.1) | ||
rspec-core (3.5.1) | ||
rspec-support (~> 3.5.0) | ||
rspec-expectations (3.5.0) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.5.0) | ||
rspec-mocks (3.5.0) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.5.0) | ||
rspec-rails (3.5.1) | ||
actionpack (>= 3.0) | ||
activesupport (>= 3.0) | ||
railties (>= 3.0) | ||
rspec-core (~> 3.5.0) | ||
rspec-expectations (~> 3.5.0) | ||
rspec-mocks (~> 3.5.0) | ||
rspec-support (~> 3.5.0) | ||
rspec-support (3.5.0) | ||
simplecov (0.12.0) | ||
docile (~> 1.1.0) | ||
json (>= 1.8, < 3) | ||
simplecov-html (~> 0.10.0) | ||
simplecov-html (0.10.0) | ||
sprockets (3.6.3) | ||
concurrent-ruby (~> 1.0) | ||
rack (> 1, < 3) | ||
sprockets-rails (3.1.1) | ||
actionpack (>= 4.0) | ||
activesupport (>= 4.0) | ||
sprockets (>= 3.0.0) | ||
sqlite3 (1.3.11) | ||
term-ansicolor (1.3.2) | ||
tins (~> 1.0) | ||
thor (0.19.1) | ||
thread_safe (0.3.5) | ||
tins (1.6.0) | ||
tzinfo (1.2.2) | ||
thread_safe (~> 0.1) | ||
warden (1.2.6) | ||
rack (>= 1.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
activity_notification! | ||
coveralls | ||
devise | ||
factory_girl_rails | ||
rspec-rails | ||
simplecov | ||
sqlite3 | ||
|
||
BUNDLED WITH | ||
1.12.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FactoryGirl.define do | ||
factory :article do | ||
user | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FactoryGirl.define do | ||
factory :notification, class: ActivityNotification::Notification do | ||
association :target, factory: :user | ||
association :notifiable, factory: :article | ||
key "default.default" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FactoryGirl.define do | ||
factory :user do | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
RSpec.describe ActivityNotification::Notification, type: :model do | ||
|
||
# --- Validation --- | ||
describe "with validation" do | ||
before { @notification = build(:notification) } | ||
|
||
it "is valid with target, notifiable and key" do | ||
expect(@notification).to be_valid | ||
end | ||
|
||
it "is invalid with blank target" do | ||
@notification.target = nil | ||
expect(@notification).to be_invalid | ||
expect(@notification.errors[:target].size).to eq(1) | ||
end | ||
|
||
it "is invalid with blank notifiable" do | ||
@notification.notifiable = nil | ||
expect(@notification).to be_invalid | ||
expect(@notification.errors[:notifiable].size).to eq(1) | ||
end | ||
|
||
it "is invalid with blank key" do | ||
@notification.key = nil | ||
expect(@notification).to be_invalid | ||
expect(@notification.errors[:key].size).to eq(1) | ||
end | ||
end | ||
|
||
describe "with association" do | ||
it "belongs to notification as group_owner" do | ||
group_owner = create(:notification, group_owner: nil) | ||
group_member = create(:notification, group_owner: group_owner) | ||
expect(group_member.group_owner).to eq(group_owner) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require File.expand_path('../config/application', __FILE__) | ||
|
||
Rails.application.load_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ApplicationController < ActionController::Base | ||
# Prevent CSRF attacks by raising an exception. | ||
# For APIs, you may want to use :null_session instead. | ||
protect_from_forgery with: :exception | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ApplicationHelper | ||
end |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Article < ActiveRecord::Base | ||
include ActivityNotification::Notifiable | ||
acts_as_notifiable :users, | ||
targets: ->(issue, key) { | ||
[user] | ||
}, | ||
notifier: :user, | ||
email_allowed: ->(article, target_user, key) { | ||
true | ||
}#, | ||
#notifiable_path: ->(article) { concept_issue_path(issue.concept, issue) } | ||
|
||
belongs_to :user | ||
has_many :comments, dependent: :delete_all | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class Comment < ActiveRecord::Base | ||
belongs_to :article | ||
belongs_to :user | ||
|
||
include ActivityNotification::Notifiable | ||
acts_as_notifiable :users, | ||
targets: :custom_notification_users, | ||
group: :article, | ||
notifier: :user, | ||
email_allowed: :custom_notification_email_to_users_allowed?#, | ||
#notifiable_path: :custom_notifiable_path | ||
|
||
def custom_notification_users(key) | ||
User.where(id: self.article.comments.pluck(:user_id)) | ||
end | ||
|
||
def custom_notification_email_to_users_allowed?(user, key) | ||
true | ||
end | ||
|
||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class User < ActiveRecord::Base | ||
# devise :database_authenticatable, :registerable, :confirmable | ||
|
||
include ActivityNotification::Target | ||
acts_as_target email: :email, email_allowed: :confirmed_at | ||
|
||
end |
Oops, something went wrong.