Commit 9f7bede3 by tady

Merge commit '3eff2d2a' into set-hipchat

Conflicts:
	config/settings.yml.example
parents 2cb6052a 3eff2d2a
......@@ -4,7 +4,7 @@ source 'https://rubygems.org'
gem 'rails', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails'
gem 'sass-rails', github: 'rails/sass-rails'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier'
......
......@@ -15,30 +15,40 @@ GIT
activesupport
gmail_xoauth
GIT
remote: git://github.com/rails/sass-rails.git
revision: 57ec3397ff99655890895df29a7bf3f683410256
specs:
sass-rails (5.0.0.dev)
railties (>= 4.0.0, < 5.0)
sass (~> 3.2)
sprockets (~> 2.12)
sprockets-rails (~> 2.0)
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.1.0)
actionpack (= 4.1.0)
actionview (= 4.1.0)
actionmailer (4.1.4)
actionpack (= 4.1.4)
actionview (= 4.1.4)
mail (~> 2.5.4)
actionpack (4.1.0)
actionview (= 4.1.0)
activesupport (= 4.1.0)
actionpack (4.1.4)
actionview (= 4.1.4)
activesupport (= 4.1.4)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionview (4.1.0)
activesupport (= 4.1.0)
actionview (4.1.4)
activesupport (= 4.1.4)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.1.0)
activesupport (= 4.1.0)
activemodel (4.1.4)
activesupport (= 4.1.4)
builder (~> 3.1)
activerecord (4.1.0)
activemodel (= 4.1.0)
activesupport (= 4.1.0)
activerecord (4.1.4)
activemodel (= 4.1.4)
activesupport (= 4.1.4)
arel (~> 5.0.0)
activesupport (4.1.0)
activesupport (4.1.4)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
......@@ -142,7 +152,7 @@ GEM
formatador (0.2.5)
gherkin (2.12.2)
multi_json (~> 1.3)
github-markdown (0.6.5)
github-markdown (0.6.6)
gmail_xoauth (0.4.1)
oauth (>= 0.3.6)
guard (2.6.1)
......@@ -151,7 +161,7 @@ GEM
lumberjack (~> 1.0)
pry (>= 0.9.12)
thor (>= 0.18.1)
guard-rspec (4.2.10)
guard-rspec (4.3.1)
guard (~> 2.1)
rspec (>= 2.14, < 4.0)
guard-rubocop (1.1.0)
......@@ -219,7 +229,7 @@ GEM
net-ssh (2.9.1)
netrc (0.7.7)
newrelic_rpm (3.9.0.229)
nokogiri (1.6.2.1)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
ntlm-http (0.1.1)
oauth (0.4.7)
......@@ -268,19 +278,19 @@ GEM
rack (>= 1.1.3)
rack-test (0.6.2)
rack (>= 1.0)
rails (4.1.0)
actionmailer (= 4.1.0)
actionpack (= 4.1.0)
actionview (= 4.1.0)
activemodel (= 4.1.0)
activerecord (= 4.1.0)
activesupport (= 4.1.0)
rails (4.1.4)
actionmailer (= 4.1.4)
actionpack (= 4.1.4)
actionview (= 4.1.4)
activemodel (= 4.1.4)
activerecord (= 4.1.4)
activesupport (= 4.1.4)
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.0)
railties (= 4.1.4)
sprockets-rails (~> 2.0)
railties (4.1.0)
actionpack (= 4.1.0)
activesupport (= 4.1.0)
railties (4.1.4)
actionpack (= 4.1.4)
activesupport (= 4.1.4)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
......@@ -292,7 +302,7 @@ GEM
rdoc (4.1.1)
json (~> 1.4)
ref (1.0.5)
request_store (1.0.7)
request_store (1.0.8)
rest-client (1.7.2)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
......@@ -300,14 +310,14 @@ GEM
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-core (3.0.2)
rspec-core (3.0.3)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.2)
rspec-expectations (3.0.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-mocks (3.0.2)
rspec-mocks (3.0.3)
rspec-support (~> 3.0.0)
rspec-rails (3.0.1)
rspec-rails (3.0.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
......@@ -315,7 +325,7 @@ GEM
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-support (~> 3.0.0)
rspec-support (3.0.2)
rspec-support (3.0.3)
rubocop (0.24.1)
json (>= 1.7.7, < 2)
parser (>= 2.2.0.pre.3, < 3.0)
......@@ -323,12 +333,7 @@ GEM
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.5.1)
sass (3.2.19)
sass-rails (4.0.3)
railties (>= 4.0.0, < 5.0)
sass (~> 3.2.0)
sprockets (~> 2.8, <= 2.11.0)
sprockets-rails (~> 2.0)
sass (3.3.11)
sdoc (0.4.0)
json (~> 1.8)
rdoc (~> 4.0, < 5.0)
......@@ -342,7 +347,7 @@ GEM
temple (~> 0.6.6)
tilt (>= 1.3.3, < 2.1)
slop (3.6.0)
sprockets (2.11.0)
sprockets (2.12.1)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
......@@ -448,7 +453,7 @@ DEPENDENCIES
rails (~> 4.1)
rspec-rails
rubocop
sass-rails
sass-rails!
sdoc
settingslogic
slim
......
# guard :rubocop do
# watch(%r{.+\.rb$})
# watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
# end
guard :rspec do
# Note: The cmd option is now required due to the increasing number of ways
# rspec may be run, below are examples of the most common uses.
# * bundler: 'bundle exec rspec'
# * bundler binstubs: 'bin/rspec'
# * spring: 'bin/rsspec' (This will use spring if running and you have
# installed the spring binstubs per the docs)
# * zeus: 'zeus rspec' (requires the server to be started separetly)
# * 'just' rspec: 'rspec'
guard :rspec, cmd: 'bundle exec rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^spec/spec_helper\.rb$}) { |m| 'spec' }
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
%W(spec/routing/#{m[1]}_routing_spec.rb spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb spec/requests/#{m[1]}_spec.rb)
end
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
watch('spec/rails_helper.rb') { "spec" }
# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
# guard :rubocop do
# watch(%r{.+\.rb$})
# watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
# end
# guard :teaspoon do
# watch(%r{^app/assets/javascripts/(.+).js}) { |m| "spec/javascripts/#{m[1]}_spec.js.coffee" }
# # Implementation files
# watch(%r{^app/assets/javascripts/(.+).js}) { |m| "#{m[1]}_spec" }
# # Specs / Helpers
# watch(%r{^spec/javascripts/(.*)})
# end
......@@ -19,11 +19,14 @@ class Notification < ActiveRecord::Base
# Named scope
######################################################################
# 最新のPostを取得
scope :unread, -> {
where(is_read: false)
}
scope :recent, -> {
where(arel_table[:created_at].gt 7.day.ago)
}
######################################################################
# Instance method
######################################################################
......
......@@ -115,7 +115,9 @@ class User < ActiveRecord::Base
# push通知を追加
def push_notification(detail_path, body)
notifications.create(detail_path: detail_path, body: body, is_read: false)
unless notifications.where(detail_path: detail_path).unread.exists?
notifications.create(detail_path: detail_path, body: body, is_read: false)
end
end
# record footprint
......
......@@ -10,6 +10,7 @@ html lang="ja"
link href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.print.css" rel="stylesheet" /
link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"
script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"
= render partial: 'partials/google_analytics'
= stylesheet_link_tag "application", media: "all"
= render_style
= csrf_meta_tags
......
......@@ -30,7 +30,7 @@ nav.navbar.navbar-fixed-top.navbar-original role="navigation"
a#notifications data-container="body" data-toggle="popover" data-placement="bottom"
span.glyphicon.glyphicon-flag
- if current_user.notifications.unread.any?
span.badge = current_user.notifications.unread.count
span.badge = current_user.notifications.unread.recent.count
li.new-post-btn
form
a.btn.navbar-btn href=new_post_path
......@@ -56,10 +56,10 @@ nav.navbar.navbar-fixed-top.navbar-original role="navigation"
a href=destroy_user_session_path data-method="delete" rel="nofollow" SignOut
script#notification-content type="text/template"
- if current_user.notifications.unread.any?
- if current_user.notifications.unread.recent.any?
h4 通知一覧
.list-group
- current_user.notifications.unread.each do |notification|
- current_user.notifications.unread.recent.each do |notification|
a.list-group-item href=notification_bridge_path(notification.id)
spen.small
| [#{notification.created_at.strftime('%m/%d %H:%M')}]&nbsp;
......
- if Settings.respond_to?(:google_analytics) && Settings.google_analytics.present?
javascript:
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '#{Settings.google_analytics}', 'auto');
ga('send', 'pageview');
......@@ -24,6 +24,9 @@ defaults: &defaults
# token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
# room: 'xxxxxxxxxxx'
# optional
# google_analytics:
development:
<<: *defaults
......
......@@ -32,6 +32,16 @@ describe Notification do
expect(@bob.notifications.size).to eq(1)
end
it "not duplicated notifies on post edited" do
@bob.watch!(post: @post)
expect(@bob.watching?(post: @post)).to be_truthy
@post.reload
expect(@post.watchers).to include(@bob)
@post.update!(title: @post.title + ' [New!]')
@post.update!(title: @post.title + ' [New!]')
expect(@bob.notifications.size).to eq(1)
end
it "not notifies on post edited by him" do
@bob.watch!(post: @post)
@post.reload
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment