enju_message 0.0.25 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/MIT-LICENSE +1 -1
  2. data/Rakefile +1 -11
  3. data/app/controllers/message_requests_controller.rb +3 -3
  4. data/app/controllers/messages_controller.rb +7 -6
  5. data/app/models/message.rb +0 -1
  6. data/app/models/message_request.rb +1 -5
  7. data/app/models/message_template.rb +0 -1
  8. data/app/views/checked_items/_checkouts.html.erb +1 -1
  9. data/app/views/checked_items/_list.html.erb +1 -1
  10. data/app/views/checkins/_list.html.erb +1 -1
  11. data/app/views/checkouts/_list.html.erb +1 -1
  12. data/app/views/checkouts/edit.html.erb +1 -1
  13. data/app/views/checkouts/show.html.erb +1 -1
  14. data/app/views/lending_policies/show.html.erb +1 -1
  15. data/app/views/message_requests/index.html.erb +1 -1
  16. data/app/views/message_templates/index.html.erb +1 -1
  17. data/app/views/messages/index.html.erb +2 -2
  18. data/app/views/messages/show.html.erb +1 -1
  19. data/app/views/notifier/message_notification.en.text.erb +2 -2
  20. data/app/views/notifier/message_notification.ja.text.erb +2 -2
  21. data/app/views/reserves/index.html.erb +1 -1
  22. data/app/views/reserves/show.html.erb +1 -1
  23. data/lib/enju_message/engine.rb +8 -1
  24. data/lib/enju_message/version.rb +1 -1
  25. data/lib/enju_message.rb +0 -3
  26. data/spec/controllers/message_requests_controller_spec.rb +2 -2
  27. data/spec/controllers/messages_controller_spec.rb +0 -4
  28. data/spec/dummy/app/models/user.rb +13 -2
  29. data/spec/dummy/config/application.rb +2 -0
  30. data/spec/dummy/config/initializers/devise.rb +4 -0
  31. data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +10 -31
  32. data/spec/dummy/db/schema.rb +5 -14
  33. data/spec/dummy/db/test.sqlite3 +0 -0
  34. data/spec/dummy/lib/enju_leaf/localized_name.rb +13 -0
  35. data/spec/dummy/lib/enju_leaf/master_model.rb +41 -0
  36. data/spec/dummy/lib/enju_leaf/url_validator.rb +10 -0
  37. data/spec/dummy/lib/enju_leaf.rb +4 -0
  38. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  39. data/spec/dummy/solr/data/test/index/segments_1 +0 -0
  40. data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
  41. data/spec/factories/message_request.rb +0 -1
  42. data/spec/spec_helper.rb +1 -1
  43. metadata +146 -27
  44. data/lib/enju_message/user.rb +0 -28
  45. data/spec/dummy/solr/data/test/index/_f.fdt +0 -0
  46. data/spec/dummy/solr/data/test/index/_f.fdx +0 -0
  47. data/spec/dummy/solr/data/test/index/_f.fnm +0 -3
  48. data/spec/dummy/solr/data/test/index/_f.frq +0 -1
  49. data/spec/dummy/solr/data/test/index/_f.nrm +0 -1
  50. data/spec/dummy/solr/data/test/index/_f.prx +0 -0
  51. data/spec/dummy/solr/data/test/index/_f.tii +0 -0
  52. data/spec/dummy/solr/data/test/index/_f.tis +0 -0
  53. data/spec/dummy/solr/data/test/index/segments_x +0 -0
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2012 Kosuke Tanabe
1
+ Copyright 2011 YOURNAME
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ end
14
14
 
15
15
  RDoc::Task.new(:rdoc) do |rdoc|
16
16
  rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'EnjuMessage'
17
+ rdoc.title = 'EnjuSubject'
18
18
  rdoc.options << '--line-numbers'
19
19
  rdoc.rdoc_files.include('README.rdoc')
20
20
  rdoc.rdoc_files.include('lib/**/*.rb')
@@ -26,15 +26,6 @@ load 'rails/tasks/engine.rake'
26
26
 
27
27
  Bundler::GemHelper.install_tasks
28
28
 
29
- require 'rake/testtask'
30
-
31
- Rake::TestTask.new(:test) do |t|
32
- t.libs << 'lib'
33
- t.libs << 'test'
34
- t.pattern = 'test/**/*_test.rb'
35
- t.verbose = false
36
- end
37
-
38
29
  require 'rspec/core'
39
30
  require 'rspec/core/rake_task'
40
31
 
@@ -42,5 +33,4 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
42
33
  spec.pattern = FileList['spec/**/*_spec.rb']
43
34
  end
44
35
 
45
-
46
36
  task :default => :spec
@@ -40,7 +40,7 @@ class MessageRequestsController < ApplicationController
40
40
  if @message_request.update_attributes(params[:message_request])
41
41
  flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.message_request'))
42
42
  format.html { redirect_to(@message_request) }
43
- format.json { head :no_content }
43
+ format.json { head :ok }
44
44
  else
45
45
  @message_templates = MessageTemplate.all
46
46
  format.html { render :action => "edit" }
@@ -55,8 +55,8 @@ class MessageRequestsController < ApplicationController
55
55
  @message_request.destroy
56
56
 
57
57
  respond_to do |format|
58
- format.html { redirect_to message_requests_url }
59
- format.json { head :no_content }
58
+ format.html { redirect_to(message_requests_url) }
59
+ format.json { head :ok }
60
60
  end
61
61
  end
62
62
  end
@@ -33,7 +33,7 @@ class MessagesController < ApplicationController
33
33
  @messages = search.execute!.results
34
34
 
35
35
  respond_to do |format|
36
- format.html # index.html.erb
36
+ format.html # index.rhtml
37
37
  format.json { render :json => @messages }
38
38
  format.rss
39
39
  format.atom
@@ -47,7 +47,7 @@ class MessagesController < ApplicationController
47
47
  @message.sm_read!
48
48
 
49
49
  respond_to do |format|
50
- format.html # show.html.erb
50
+ format.html # show.rhtml
51
51
  format.json { render :json => @message }
52
52
  end
53
53
  end
@@ -77,14 +77,14 @@ class MessagesController < ApplicationController
77
77
  # POST /messages
78
78
  # POST /messages.json
79
79
  def create
80
- @message = Message.new(params[:message])
81
- @message.sender = current_user
80
+ @message = current_user.sent_messages.new(params[:message])
82
81
  get_parent(@message.parent_id)
83
82
  @message.receiver = User.find(@message.recipient) rescue nil
84
83
 
85
84
  respond_to do |format|
86
85
  if @message.save
87
- format.html { redirect_to messages_url, :notice => t('controller.successfully_created', :model => t('activerecord.models.message')) }
86
+ flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.message'))
87
+ format.html { redirect_to messages_url }
88
88
  format.json { render :json => @message, :status => :created, :location => @message }
89
89
  else
90
90
  format.html { render :action => "new" }
@@ -99,7 +99,8 @@ class MessagesController < ApplicationController
99
99
  @message = current_user.received_messages.find(params[:id])
100
100
 
101
101
  if @message.update_attributes(params[:message])
102
- format.html { redirect_to @message, :notice => t('controller.successfully_updated', :model => t('activerecord.models.message')) }
102
+ flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.message'))
103
+ format.html { redirect_to @message }
103
104
  format.json { head :no_content }
104
105
  else
105
106
  format.html { render :action => "edit" }
@@ -1,6 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  class Message < ActiveRecord::Base
3
- attr_accessible :subject, :body, :sender, :recipient
4
3
  scope :unread, where(:state => 'unread')
5
4
  belongs_to :message_request
6
5
  belongs_to :sender, :class_name => 'User'
@@ -1,7 +1,5 @@
1
1
  require 'erubis'
2
2
  class MessageRequest < ActiveRecord::Base
3
- attr_accessible :body
4
- attr_accessible :sender, :receiver, :message_template, :body, :as => :admin
5
3
  scope :not_sent, where('sent_at IS NULL AND state = ?', 'pending')
6
4
  scope :sent, where(:state => 'sent')
7
5
  scope :started, where(:state => 'started')
@@ -12,7 +10,6 @@ class MessageRequest < ActiveRecord::Base
12
10
 
13
11
  validates_associated :sender, :receiver, :message_template
14
12
  validates_presence_of :sender, :receiver, :message_template
15
- validates_presence_of :body, :on => :update
16
13
 
17
14
  state_machine :initial => :pending do
18
15
  before_transition any - :sent => :sent, :do => :send_message
@@ -43,8 +40,7 @@ class MessageRequest < ActiveRecord::Base
43
40
  else
44
41
  raise 'body is empty!'
45
42
  end
46
- self.sent_at = Time.zone.now
47
- save!
43
+ self.update_attributes({:sent_at => Time.zone.now})
48
44
  if ['reservation_expired_for_patron', 'reservation_expired_for_patron'].include?(self.message_template.status)
49
45
  self.receiver.reserves.each do |reserve|
50
46
  reserve.update_attribute(:expiration_notice_to_patron, true)
@@ -1,5 +1,4 @@
1
1
  class MessageTemplate < ActiveRecord::Base
2
- attr_accessible :status, :title, :body, :locale
3
2
  default_scope :order => "message_templates.position"
4
3
  has_many :message_requests
5
4
 
@@ -14,7 +14,7 @@
14
14
  <%= render 'manifestations/holding', :manifestation => checkout.item.manifestation -%>
15
15
  </td>
16
16
  <td><%= link_to checkout.item.item_identifier, checkout.item -%></td>
17
- <td><%= l(checkout.due_date, :formats => :only_date) -%></td>
17
+ <td><%= l(checkout.due_date, :format => :only_date) -%></td>
18
18
  </tr>
19
19
  <%- end -%>
20
20
  </table>
@@ -26,7 +26,7 @@
26
26
  <%= render 'manifestations/show_index', :manifestation => checked_item.item.manifestation -%>
27
27
  </td>
28
28
  <td><%= link_to checked_item.item.item_identifier, checked_item.item -%></td>
29
- <td><%= l(checked_item.due_date, :formats => :only_date) -%></td>
29
+ <td><%= l(checked_item.due_date, :format => :only_date) -%></td>
30
30
  <td><%= link_to t('page.destroy'), checked_item, :confirm => t('page.are_you_sure'), :method => :delete -%></td>
31
31
  </tr>
32
32
  <%- end -%>
@@ -36,7 +36,7 @@
36
36
  </td>
37
37
  <td>
38
38
  <%- if checkin.checkout -%>
39
- <%= l(checkin.checkout.due_date, :formats => :only_date) -%>
39
+ <%= l(checkin.checkout.due_date, :format => :only_date) -%>
40
40
  <%- end -%>
41
41
  </td>
42
42
  <td>
@@ -21,7 +21,7 @@
21
21
  (<%= link_to checkout.item.item_identifier, checkout.item -%>)
22
22
  </td>
23
23
  <td>
24
- <%= l(checkout.due_date, :formats => :only_date) -%>
24
+ <%= l(checkout.due_date, :format => :only_date) -%>
25
25
  <br />
26
26
  <% if checkout.checkin %>
27
27
  <strong><%= t('checkout.returned') %></strong>
@@ -7,7 +7,7 @@
7
7
  <h3><%= t('checkout.renewal') -%></h3>
8
8
  <%- if @checkout.checkout_renewable? -%>
9
9
  <%= form_for(@checkout) do |f| -%>
10
- <%= t('checkout.new_due_date') -%>: <%= l(@new_due_date, :formats => :only_date) if @new_due_date -%>
10
+ <%= t('checkout.new_due_date') -%>: <%= l(@new_due_date, :format => :only_date) if @new_due_date -%>
11
11
  <%= f.hidden_field :due_date, :value => @new_due_date -%>
12
12
  <br />
13
13
  <%= f.submit %>
@@ -10,7 +10,7 @@
10
10
  </p>
11
11
  <p>
12
12
  <strong><%= t('activerecord.attributes.checkout.due_date') -%></strong><br />
13
- <%= l(@checkout.due_date, :formats => :only_date) if @checkout.due_date -%>
13
+ <%= l(@checkout.due_date, :format => :only_date) if @checkout.due_date -%>
14
14
  </p>
15
15
  <%- if can? :destroy, @checkout -%>
16
16
  <p>
@@ -21,7 +21,7 @@
21
21
 
22
22
  <p>
23
23
  <strong><%= t('activerecord.attributes.lending_policy.fixed_due_date') -%>:</strong>
24
- <%= l(@lending_policy.fixed_due_date, :formats => :only_date) if @lending_policy.fixed_due_date -%>
24
+ <%= l(@lending_policy.fixed_due_date, :format => :only_date) if @lending_policy.fixed_due_date -%>
25
25
  </p>
26
26
 
27
27
  <p>
@@ -31,7 +31,7 @@
31
31
  <td>
32
32
  <%= link_to t('page.show'), message_request -%>
33
33
  <%= link_to t('page.edit'), edit_message_request_path(message_request) -%>
34
- <%= link_to t('page.destroy'), message_request, :data => {:confirm => t('page.are_you_sure')}, :method => :delete -%>
34
+ <%= link_to t('page.destroy'), message_request, :confirm => t('page.are_you_sure'), :method => :delete -%>
35
35
  </td>
36
36
  </tr>
37
37
  <%- end -%>
@@ -26,7 +26,7 @@
26
26
  <%= link_to t('page.edit'), edit_message_template_path(message_template) -%>
27
27
  <% end %>
28
28
  <%- if can? :destroy, message_template -%>
29
- <%= link_to t('page.destroy'), message_template, :data => {:confirm => t('page.are_you_sure')}, :method => :delete -%>
29
+ <%= link_to t('page.destroy'), message_template, :confirm => t('page.are_you_sure'), :method => :delete -%>
30
30
  <%- end -%>
31
31
  </td>
32
32
  </tr>
@@ -48,13 +48,13 @@
48
48
  <li>
49
49
  <% facet.value ? facet_mode = 'read' : facet_mode = 'unread' %>
50
50
  <%- if facet_mode == mode -%><strong><%- end -%>
51
- <%= link_to t("message.#{facet_mode}"), url_for(params.merge(:page => nil, :mode => facet_mode, :only_path => true)) -%>
51
+ <%= link_to t("message.#{facet_mode}"), url_for(params.merge(:page => nil, :mode => facet_mode)) -%>
52
52
  (<%= facet.count -%>)
53
53
  <%- if facet_mode == mode -%></strong><%- end -%>
54
54
  </li>
55
55
  <%- end -%>
56
56
  <% if mode.present? %>
57
- <li><%= link_to t('page.remove_this_facet'), url_for(params.merge(:mode => nil, :page => nil, :only_path => true)) -%></li>
57
+ <li><%= link_to t('page.remove_this_facet'), url_for(params.merge(:mode => nil, :page => nil)) -%></li>
58
58
  <% end %>
59
59
  </ul>
60
60
 
@@ -42,7 +42,7 @@
42
42
  <% end %>
43
43
  <li><%= link_to t('message.reply'), new_message_path(:parent_id => @message.id) -%></li>
44
44
  <% if can? :destroy, :message %>
45
- <li><%= link_to t('page.destroy'), @message, :data => {:confirm => t('page.are_you_sure')}, :method => :delete -%></li>
45
+ <li><%= link_to t('page.destroy'), @message, :confirm => t('page.are_you_sure'), :method => :delete -%></li>
46
46
  <% end %>
47
47
  </ul>
48
48
  </div>
@@ -1,11 +1,11 @@
1
- <%= @message.receiver.patron.full_name -%> :
1
+ <%= @message.receiver.full_name -%> :
2
2
 
3
3
  A new message arrived from <%= @sender_name -%>.
4
4
  <%= messages_url %>
5
5
 
6
6
  -----
7
7
 
8
- <%=raw @message.body %>
8
+ <%= @message.body %>
9
9
 
10
10
  -----
11
11
 
@@ -1,11 +1,11 @@
1
- <%= @message.receiver.patron.full_name -%> さん
1
+ <%= @message.receiver.full_name -%> さん
2
2
 
3
3
  <%= @sender_name -%> さんから新しいメッセージが届きました。
4
4
  <%= messages_url %>
5
5
 
6
6
  -----
7
7
 
8
- <%=raw @message.body %>
8
+ <%= @message.body %>
9
9
 
10
10
  -----
11
11
 
@@ -22,7 +22,7 @@
22
22
  <%= render 'title', :reserve => reserve -%>
23
23
  </td>
24
24
  <td><%= i18n_state(reserve.state) -%></td>
25
- <td><%= l(reserve.expired_at, :formats => :only_date) -%></td>
25
+ <td><%= l(reserve.expired_at, :format => :only_date) -%></td>
26
26
  <%- if can? :destroy, reserve -%>
27
27
  <td>
28
28
  <%= link_to t('page.edit'), edit_reserve_path(reserve) -%>
@@ -33,7 +33,7 @@
33
33
 
34
34
  <p>
35
35
  <strong><%= t('activerecord.attributes.reserve.expired_at') -%>:</strong>
36
- <%= l(@reserve.expired_at, :formats => :only_date) if @reserve.expired_at -%>
36
+ <%= l(@reserve.expired_at, :format => :only_date) if @reserve.expired_at -%>
37
37
  </p>
38
38
 
39
39
  <p>
@@ -1,9 +1,16 @@
1
- require 'enju_core'
2
1
  require 'configatron'
3
2
  require 'delayed_job_active_record'
3
+ require 'devise'
4
+ require 'cancan'
4
5
  require 'state_machine'
5
6
  require 'inherited_resources'
7
+ require 'attribute_normalizer'
8
+ require 'addressable/uri'
9
+ require 'friendly_id'
6
10
  require 'awesome_nested_set'
11
+ require 'will_paginate'
12
+ require 'sunspot_rails'
13
+ require 'acts_as_list'
7
14
 
8
15
  module EnjuMessage
9
16
  class Engine < ::Rails::Engine
@@ -1,3 +1,3 @@
1
1
  module EnjuMessage
2
- VERSION = "0.0.25"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/enju_message.rb CHANGED
@@ -1,7 +1,4 @@
1
1
  require "enju_message/engine"
2
- require "enju_message/user"
3
2
 
4
3
  module EnjuMessage
5
4
  end
6
-
7
- ActiveRecord::Base.send :include, EnjuMessage::MessageUser
@@ -124,8 +124,8 @@ describe MessageRequestsController do
124
124
  describe "PUT update" do
125
125
  before(:each) do
126
126
  @message_request = FactoryGirl.create(:message_request)
127
- @attrs = FactoryGirl.attributes_for(:message_request).merge(:body => 'test')
128
- @invalid_attrs = {:body => ''}
127
+ @attrs = FactoryGirl.attributes_for(:message_request)
128
+ @invalid_attrs = {:sender_id => ''}
129
129
  end
130
130
 
131
131
  describe "When logged in as Administrator" do
@@ -4,10 +4,6 @@ describe MessagesController do
4
4
  fixtures :all
5
5
 
6
6
  describe "GET index", :solr => true do
7
- before do
8
- Message.reindex
9
- end
10
-
11
7
  describe "When logged in as Administrator" do
12
8
  before(:each) do
13
9
  @user = FactoryGirl.create(:admin)
@@ -12,10 +12,10 @@ class User < ActiveRecord::Base
12
12
  has_one :patron
13
13
  belongs_to :user_group
14
14
  belongs_to :required_role, :class_name => 'Role', :foreign_key => 'required_role_id'
15
+ has_many :sent_messages, :foreign_key => 'sender_id', :class_name => 'Message'
16
+ has_many :received_messages, :foreign_key => 'receiver_id', :class_name => 'Message'
15
17
  before_create :set_role_and_patron
16
18
 
17
- enju_message_user
18
-
19
19
  extend FriendlyId
20
20
  friendly_id :username
21
21
 
@@ -39,4 +39,15 @@ class User < ActiveRecord::Base
39
39
  false
40
40
  end
41
41
  end
42
+
43
+ def send_message(status, options = {})
44
+ MessageRequest.transaction do
45
+ request = MessageRequest.new
46
+ request.sender = User.find(1)
47
+ request.receiver = self
48
+ request.message_template = MessageTemplate.localized_template(status, self.locale)
49
+ request.save_message_body(options)
50
+ request.sm_send_message!
51
+ end
52
+ end
42
53
  end
@@ -42,3 +42,5 @@ module Dummy
42
42
  config.assets.version = '1.0'
43
43
  end
44
44
  end
45
+
46
+ require 'enju_leaf'
@@ -92,6 +92,10 @@ Devise.setup do |config|
92
92
  # If true, extends the user's remember period when remembered via cookie.
93
93
  # config.extend_remember_period = false
94
94
 
95
+ # If true, uses the password salt as remember token. This should be turned
96
+ # to false if you are not using database authenticatable.
97
+ config.use_salt_as_remember_token = true
98
+
95
99
  # Options to be passed to the created cookie. For instance, you can set
96
100
  # :secure => true in order to force SSL only cookies.
97
101
  # config.cookie_options = {}
@@ -1,40 +1,19 @@
1
1
  class AddDeviseToUsers < ActiveRecord::Migration
2
2
  def self.up
3
3
  change_table(:users) do |t|
4
- ## Database authenticatable
5
- t.string :email, :null => false, :default => ""
6
- t.string :encrypted_password, :null => false, :default => ""
4
+ t.database_authenticatable :null => false
5
+ t.recoverable
6
+ t.rememberable
7
+ t.trackable
7
8
 
8
- ## Recoverable
9
- t.string :reset_password_token
10
- t.datetime :reset_password_sent_at
9
+ # t.encryptable
10
+ # t.confirmable
11
+ # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
12
+ # t.token_authenticatable
11
13
 
12
- ## Rememberable
13
- t.datetime :remember_created_at
14
14
 
15
- ## Trackable
16
- t.integer :sign_in_count, :default => 0
17
- t.datetime :current_sign_in_at
18
- t.datetime :last_sign_in_at
19
- t.string :current_sign_in_ip
20
- t.string :last_sign_in_ip
21
-
22
- ## Encryptable
23
- t.string :password_salt
24
-
25
- ## Confirmable
26
- t.string :confirmation_token
27
- t.datetime :confirmed_at
28
- t.datetime :confirmation_sent_at
29
- t.string :unconfirmed_email # Only if using reconfirmable
30
-
31
- ## Lockable
32
- t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
33
- t.string :unlock_token # Only if unlock strategy is :email or :both
34
- t.datetime :locked_at
35
-
36
- # Token authenticatable
37
- t.string :authentication_token
15
+ # Uncomment below if timestamps were not included in your original model.
16
+ # t.timestamps
38
17
  end
39
18
 
40
19
  add_index :users, :email #, :unique => true
@@ -207,27 +207,18 @@ ActiveRecord::Schema.define(:version => 20120213092115) do
207
207
  t.text "note"
208
208
  t.string "locale"
209
209
  t.string "user_number"
210
- t.datetime "created_at", :null => false
211
- t.datetime "updated_at", :null => false
212
- t.string "email", :default => "", :null => false
213
- t.string "encrypted_password", :default => "", :null => false
210
+ t.datetime "created_at", :null => false
211
+ t.datetime "updated_at", :null => false
212
+ t.string "email", :default => "", :null => false
213
+ t.string "encrypted_password", :limit => 128, :default => "", :null => false
214
214
  t.string "reset_password_token"
215
215
  t.datetime "reset_password_sent_at"
216
216
  t.datetime "remember_created_at"
217
- t.integer "sign_in_count", :default => 0
217
+ t.integer "sign_in_count", :default => 0
218
218
  t.datetime "current_sign_in_at"
219
219
  t.datetime "last_sign_in_at"
220
220
  t.string "current_sign_in_ip"
221
221
  t.string "last_sign_in_ip"
222
- t.string "password_salt"
223
- t.string "confirmation_token"
224
- t.datetime "confirmed_at"
225
- t.datetime "confirmation_sent_at"
226
- t.string "unconfirmed_email"
227
- t.integer "failed_attempts", :default => 0
228
- t.string "unlock_token"
229
- t.datetime "locked_at"
230
- t.string "authentication_token"
231
222
  end
232
223
 
233
224
  add_index "users", ["email"], :name => "index_users_on_email"
Binary file
@@ -0,0 +1,13 @@
1
+ module LocalizedName
2
+ def localize(locale = I18n.locale.to_s)
3
+ values = Hash[*self.strip.split("\n").map{|n| n.split(':', 2)}.flatten]
4
+ name = values[locale.to_s] || self
5
+ name.strip
6
+ rescue ArgumentError
7
+ self
8
+ end
9
+ end
10
+
11
+ class String
12
+ include LocalizedName
13
+ end
@@ -0,0 +1,41 @@
1
+ module MasterModel
2
+ def self.included(base)
3
+ #base.extend ClassMethods
4
+ base.send :include, InstanceMethods
5
+ base.class_eval do
6
+ acts_as_list
7
+ validates_uniqueness_of :name, :case_sensitive => false
8
+ validates_presence_of :name, :display_name
9
+ before_validation :set_display_name, :on => :create
10
+ normalize_attributes :name
11
+ end
12
+ end
13
+
14
+ module InstanceMethods
15
+ def set_display_name
16
+ self.display_name = self.name if self.display_name.blank?
17
+ end
18
+
19
+ def check_creatable
20
+ if creatable?
21
+ raise NotModifiableError
22
+ end
23
+ end
24
+
25
+ def check_deletable
26
+ if deletable?
27
+ raise NotModifiableError
28
+ end
29
+ end
30
+
31
+ def creatable?
32
+ false
33
+ end
34
+
35
+ def deletable?
36
+ false
37
+ end
38
+ end
39
+
40
+ class NotModifiableError < StandardError; end
41
+ end
@@ -0,0 +1,10 @@
1
+ class UrlValidator < ActiveModel::EachValidator
2
+ def validate_each(record, attribute, value)
3
+ url = ::Addressable::URI.parse(value)
4
+ if url
5
+ unless ['http', 'https'].include?(url.scheme)
6
+ record.errors.add(attribute.to_sym)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ require 'addressable/uri'
2
+ require 'enju_leaf/localized_name'
3
+ require 'enju_leaf/master_model'
4
+ require 'enju_leaf/url_validator'
@@ -3,6 +3,5 @@ FactoryGirl.define do
3
3
  f.sender_id{FactoryGirl.create(:user).id}
4
4
  f.receiver_id{FactoryGirl.create(:user).id}
5
5
  f.message_template_id{FactoryGirl.create(:message_template).id}
6
- f.body 'test'
7
6
  end
8
7
  end
data/spec/spec_helper.rb CHANGED
@@ -38,7 +38,7 @@ RSpec.configure do |config|
38
38
  config.before :each, :solr => true do
39
39
  Sunspot::Rails::Tester.start_original_sunspot_session
40
40
  Sunspot.session = $original_sunspot_session
41
- Sunspot.remove_all!
41
+ #Sunspot.remove_all!
42
42
  end
43
43
  end
44
44
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enju_message
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.25
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-21 00:00:00.000000000 Z
12
+ date: 2012-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -91,6 +91,70 @@ dependencies:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
93
  version: '2.1'
94
+ - !ruby/object:Gem::Dependency
95
+ name: friendly_id
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '4.0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '4.0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: will_paginate
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '3.0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '3.0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: devise
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: cancan
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
94
158
  - !ruby/object:Gem::Dependency
95
159
  name: state_machine
96
160
  requirement: !ruby/object:Gem::Requirement
@@ -124,7 +188,55 @@ dependencies:
124
188
  - !ruby/object:Gem::Version
125
189
  version: '0'
126
190
  - !ruby/object:Gem::Dependency
127
- name: enju_core
191
+ name: addressable
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ type: :runtime
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: attribute_normalizer
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ~>
212
+ - !ruby/object:Gem::Version
213
+ version: '1.1'
214
+ type: :runtime
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ~>
220
+ - !ruby/object:Gem::Version
221
+ version: '1.1'
222
+ - !ruby/object:Gem::Dependency
223
+ name: sunspot_rails
224
+ requirement: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ! '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ! '>='
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
238
+ - !ruby/object:Gem::Dependency
239
+ name: sunspot_solr
128
240
  requirement: !ruby/object:Gem::Requirement
129
241
  none: false
130
242
  requirements:
@@ -139,6 +251,22 @@ dependencies:
139
251
  - - ! '>='
140
252
  - !ruby/object:Gem::Version
141
253
  version: '0'
254
+ - !ruby/object:Gem::Dependency
255
+ name: acts_as_list
256
+ requirement: !ruby/object:Gem::Requirement
257
+ none: false
258
+ requirements:
259
+ - - ~>
260
+ - !ruby/object:Gem::Version
261
+ version: 0.1.6
262
+ type: :runtime
263
+ prerelease: false
264
+ version_requirements: !ruby/object:Gem::Requirement
265
+ none: false
266
+ requirements:
267
+ - - ~>
268
+ - !ruby/object:Gem::Version
269
+ version: 0.1.6
142
270
  - !ruby/object:Gem::Dependency
143
271
  name: sqlite3
144
272
  requirement: !ruby/object:Gem::Requirement
@@ -188,21 +316,21 @@ dependencies:
188
316
  - !ruby/object:Gem::Version
189
317
  version: '0'
190
318
  - !ruby/object:Gem::Dependency
191
- name: sunspot_solr
319
+ name: sunspot-rails-tester
192
320
  requirement: !ruby/object:Gem::Requirement
193
321
  none: false
194
322
  requirements:
195
- - - ~>
323
+ - - ! '>='
196
324
  - !ruby/object:Gem::Version
197
- version: 2.0.0.pre.120720
325
+ version: '0'
198
326
  type: :development
199
327
  prerelease: false
200
328
  version_requirements: !ruby/object:Gem::Requirement
201
329
  none: false
202
330
  requirements:
203
- - - ~>
331
+ - - ! '>='
204
332
  - !ruby/object:Gem::Version
205
- version: 2.0.0.pre.120720
333
+ version: '0'
206
334
  description: Message management for Next-L Enju
207
335
  email:
208
336
  - tanabe@mwr.mediacom.keio.ac.jp
@@ -365,7 +493,6 @@ files:
365
493
  - db/migrate/20110913115320_add_lft_and_rgt_to_message.rb
366
494
  - db/migrate/20120125050502_add_depth_to_message.rb
367
495
  - lib/enju_message/engine.rb
368
- - lib/enju_message/user.rb
369
496
  - lib/enju_message/version.rb
370
497
  - lib/enju_message.rb
371
498
  - lib/tasks/enju_message_tasks.rake
@@ -432,6 +559,10 @@ files:
432
559
  - spec/dummy/db/production.sqlite3
433
560
  - spec/dummy/db/schema.rb
434
561
  - spec/dummy/db/test.sqlite3
562
+ - spec/dummy/lib/enju_leaf/localized_name.rb
563
+ - spec/dummy/lib/enju_leaf/master_model.rb
564
+ - spec/dummy/lib/enju_leaf/url_validator.rb
565
+ - spec/dummy/lib/enju_leaf.rb
435
566
  - spec/dummy/public/404.html
436
567
  - spec/dummy/public/422.html
437
568
  - spec/dummy/public/500.html
@@ -449,16 +580,8 @@ files:
449
580
  - spec/dummy/solr/conf/spellings.txt
450
581
  - spec/dummy/solr/conf/stopwords.txt
451
582
  - spec/dummy/solr/conf/synonyms.txt
452
- - spec/dummy/solr/data/test/index/_f.fdt
453
- - spec/dummy/solr/data/test/index/_f.fdx
454
- - spec/dummy/solr/data/test/index/_f.fnm
455
- - spec/dummy/solr/data/test/index/_f.frq
456
- - spec/dummy/solr/data/test/index/_f.nrm
457
- - spec/dummy/solr/data/test/index/_f.prx
458
- - spec/dummy/solr/data/test/index/_f.tii
459
- - spec/dummy/solr/data/test/index/_f.tis
460
583
  - spec/dummy/solr/data/test/index/segments.gen
461
- - spec/dummy/solr/data/test/index/segments_x
584
+ - spec/dummy/solr/data/test/index/segments_1
462
585
  - spec/dummy/solr/data/test/spellchecker/segments.gen
463
586
  - spec/dummy/solr/data/test/spellchecker/segments_1
464
587
  - spec/factories/message.rb
@@ -565,6 +688,10 @@ test_files:
565
688
  - spec/dummy/db/production.sqlite3
566
689
  - spec/dummy/db/schema.rb
567
690
  - spec/dummy/db/test.sqlite3
691
+ - spec/dummy/lib/enju_leaf/localized_name.rb
692
+ - spec/dummy/lib/enju_leaf/master_model.rb
693
+ - spec/dummy/lib/enju_leaf/url_validator.rb
694
+ - spec/dummy/lib/enju_leaf.rb
568
695
  - spec/dummy/public/404.html
569
696
  - spec/dummy/public/422.html
570
697
  - spec/dummy/public/500.html
@@ -582,16 +709,8 @@ test_files:
582
709
  - spec/dummy/solr/conf/spellings.txt
583
710
  - spec/dummy/solr/conf/stopwords.txt
584
711
  - spec/dummy/solr/conf/synonyms.txt
585
- - spec/dummy/solr/data/test/index/_f.fdt
586
- - spec/dummy/solr/data/test/index/_f.fdx
587
- - spec/dummy/solr/data/test/index/_f.fnm
588
- - spec/dummy/solr/data/test/index/_f.frq
589
- - spec/dummy/solr/data/test/index/_f.nrm
590
- - spec/dummy/solr/data/test/index/_f.prx
591
- - spec/dummy/solr/data/test/index/_f.tii
592
- - spec/dummy/solr/data/test/index/_f.tis
593
712
  - spec/dummy/solr/data/test/index/segments.gen
594
- - spec/dummy/solr/data/test/index/segments_x
713
+ - spec/dummy/solr/data/test/index/segments_1
595
714
  - spec/dummy/solr/data/test/spellchecker/segments.gen
596
715
  - spec/dummy/solr/data/test/spellchecker/segments_1
597
716
  - spec/factories/message.rb
@@ -1,28 +0,0 @@
1
- module EnjuMessage
2
- module MessageUser
3
- def self.included(base)
4
- base.extend ClassMethods
5
- end
6
-
7
- module ClassMethods
8
- def enju_message_user
9
- include InstanceMethods
10
- has_many :sent_messages, :foreign_key => 'sender_id', :class_name => 'Message'
11
- has_many :received_messages, :foreign_key => 'receiver_id', :class_name => 'Message'
12
- end
13
- end
14
-
15
- module InstanceMethods
16
- def send_message(status, options = {})
17
- MessageRequest.transaction do
18
- request = MessageRequest.new
19
- request.sender = self.class.find(1)
20
- request.receiver = self
21
- request.message_template = MessageTemplate.localized_template(status, self.locale)
22
- request.save_message_body(options)
23
- request.sm_send_message!
24
- end
25
- end
26
- end
27
- end
28
- end
Binary file
Binary file
@@ -1,3 +0,0 @@
1
- ����
2
- idtype
3
- class_name subject_s
@@ -1 +0,0 @@
1
- 
@@ -1 +0,0 @@
1
- NRM�vvvxyxy|
Binary file
Binary file
Binary file