inboxes 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/.rspec +1 -0
- data/README.md +16 -8
- data/Rakefile +4 -0
- data/app/controllers/inboxes/base_controller.rb +0 -6
- data/app/controllers/inboxes/discussions_controller.rb +5 -22
- data/app/controllers/inboxes/messages_controller.rb +0 -9
- data/app/controllers/inboxes/speakers_controller.rb +0 -2
- data/app/helpers/inboxes_helper.rb +1 -2
- data/app/models/discussion.rb +0 -2
- data/config/locales/en.yml +1 -1
- data/config/locales/ru.yml +1 -1
- data/inboxes.gemspec +7 -5
- data/lib/inboxes.rb +2 -4
- data/lib/inboxes/engine.rb +0 -7
- data/lib/inboxes/railtie.rb +0 -1
- data/lib/inboxes/version.rb +1 -1
- data/spec/devise_config.rb +210 -0
- data/spec/fake_app.rb +97 -0
- data/spec/fake_gem.rb +6 -0
- data/spec/inboxes/discussion_spec.rb +104 -0
- data/spec/inboxes/discussions_controller_spec.rb +96 -0
- data/spec/inboxes/discussions_routing_spec.rb +23 -0
- data/spec/inboxes/message_spec.rb +27 -0
- data/spec/inboxes/messages_controller_spec.rb +42 -0
- data/spec/inboxes/speaker_spec.rb +16 -0
- data/spec/inboxes/speakers_controller_spec.rb +72 -0
- data/spec/inboxes_spec.rb +0 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/support/factories.rb +23 -0
- metadata +172 -37
- data/app/models/inboxes/ability.rb +0 -38
- data/lib/inboxes/ability.rb +0 -29
File without changes
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rails'
|
4
|
+
require 'active_record'
|
5
|
+
require 'inboxes'
|
6
|
+
# require 'database_cleaner'
|
7
|
+
# Ensure we use 'syck' instead of 'psych' in 1.9.2
|
8
|
+
# RubyGems >= 1.5.0 uses 'psych' on 1.9.2, but
|
9
|
+
# Psych does not yet support YAML 1.1 merge keys.
|
10
|
+
# Merge keys is often used in mongoid.yml
|
11
|
+
# See: http://redmine.ruby-lang.org/issues/show/4300
|
12
|
+
if RUBY_VERSION >= '1.9.2'
|
13
|
+
YAML::ENGINE.yamler = 'syck'
|
14
|
+
end
|
15
|
+
# require 'fake_gem'
|
16
|
+
require 'fake_app'
|
17
|
+
|
18
|
+
require 'rspec/rails'
|
19
|
+
# Requires supporting files with custom matchers and macros, etc,
|
20
|
+
# in ./support/ and its subdirectories.
|
21
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
22
|
+
|
23
|
+
# RSpec.configure do |config|
|
24
|
+
# config.mock_with :rr
|
25
|
+
# config.before :all do
|
26
|
+
# # ActiveRecord::Base.connection.execute 'CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))' unless ActiveRecord::Base.connection.table_exists? 'users'
|
27
|
+
# # CreateAllTables.up unless ActiveRecord::Base.connection.table_exists? 'users'
|
28
|
+
# end
|
29
|
+
# end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# FactoryGirl.define do
|
2
|
+
#
|
3
|
+
# factory :user do
|
4
|
+
# email {Factory.next(:email)}
|
5
|
+
# first_name 'user'
|
6
|
+
# last_name 'usered'
|
7
|
+
# username {Factory.next(:login)}
|
8
|
+
# password "foobar"
|
9
|
+
# password_confirmation { |u| u.password }
|
10
|
+
# role 2
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# factory :discussion do
|
14
|
+
# recipient_ids {[Factory(:user).id, Factory(:user).id]}
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# factory :message do
|
18
|
+
# association :user
|
19
|
+
# association :discussion
|
20
|
+
# # user {Factory(:user)}
|
21
|
+
# # discussion {Factory(:discussion)}
|
22
|
+
# end
|
23
|
+
# end
|
metadata
CHANGED
@@ -1,46 +1,147 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: inboxes
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Kir Shatrov
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-01-28 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: haml-rails
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: devise
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
17
38
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
22
46
|
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rails
|
23
50
|
prerelease: false
|
24
|
-
|
25
|
-
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
26
63
|
name: cancan
|
27
|
-
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
28
66
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
33
74
|
type: :runtime
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: sqlite3
|
34
78
|
prerelease: false
|
35
|
-
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
type: :development
|
89
|
+
version_requirements: *id005
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: rspec
|
92
|
+
prerelease: false
|
93
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
type: :development
|
103
|
+
version_requirements: *id006
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: factory_girl
|
106
|
+
prerelease: false
|
107
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ~>
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 11
|
113
|
+
segments:
|
114
|
+
- 1
|
115
|
+
- 2
|
116
|
+
version: "1.2"
|
117
|
+
type: :development
|
118
|
+
version_requirements: *id007
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: rspec-rails
|
121
|
+
prerelease: false
|
122
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: 3
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
131
|
+
type: :development
|
132
|
+
version_requirements: *id008
|
36
133
|
description: Messaging system for Rails 3 app
|
37
|
-
email:
|
134
|
+
email:
|
38
135
|
- shatrov@me.com
|
39
136
|
executables: []
|
137
|
+
|
40
138
|
extensions: []
|
139
|
+
|
41
140
|
extra_rdoc_files: []
|
42
|
-
|
141
|
+
|
142
|
+
files:
|
43
143
|
- .gitignore
|
144
|
+
- .rspec
|
44
145
|
- Gemfile
|
45
146
|
- README.md
|
46
147
|
- Rakefile
|
@@ -50,7 +151,6 @@ files:
|
|
50
151
|
- app/controllers/inboxes/speakers_controller.rb
|
51
152
|
- app/helpers/inboxes_helper.rb
|
52
153
|
- app/models/discussion.rb
|
53
|
-
- app/models/inboxes/ability.rb
|
54
154
|
- app/models/message.rb
|
55
155
|
- app/models/speaker.rb
|
56
156
|
- app/views/inboxes/discussions/_form.html.haml
|
@@ -69,35 +169,70 @@ files:
|
|
69
169
|
- lib/generators/inboxes/upgrade_discussible_generator.rb
|
70
170
|
- lib/generators/inboxes/views_generator.rb
|
71
171
|
- lib/inboxes.rb
|
72
|
-
- lib/inboxes/ability.rb
|
73
172
|
- lib/inboxes/active_record_extension.rb
|
74
173
|
- lib/inboxes/engine.rb
|
75
174
|
- lib/inboxes/railtie.rb
|
76
175
|
- lib/inboxes/version.rb
|
176
|
+
- log/development.log
|
177
|
+
- spec/devise_config.rb
|
178
|
+
- spec/fake_app.rb
|
179
|
+
- spec/fake_gem.rb
|
180
|
+
- spec/inboxes/discussion_spec.rb
|
181
|
+
- spec/inboxes/discussions_controller_spec.rb
|
182
|
+
- spec/inboxes/discussions_routing_spec.rb
|
183
|
+
- spec/inboxes/message_spec.rb
|
184
|
+
- spec/inboxes/messages_controller_spec.rb
|
185
|
+
- spec/inboxes/speaker_spec.rb
|
186
|
+
- spec/inboxes/speakers_controller_spec.rb
|
187
|
+
- spec/inboxes_spec.rb
|
188
|
+
- spec/spec_helper.rb
|
189
|
+
- spec/support/factories.rb
|
77
190
|
- vendor/assets/javascripts/inboxes/faye.js
|
78
191
|
- vendor/assets/javascripts/inboxes/faye/init.js.coffee
|
79
192
|
homepage: http://evrone.com/
|
80
193
|
licenses: []
|
194
|
+
|
81
195
|
post_install_message:
|
82
196
|
rdoc_options: []
|
83
|
-
|
197
|
+
|
198
|
+
require_paths:
|
84
199
|
- lib
|
85
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
200
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
201
|
none: false
|
87
|
-
requirements:
|
88
|
-
- -
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
|
91
|
-
|
202
|
+
requirements:
|
203
|
+
- - ">="
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
hash: 3
|
206
|
+
segments:
|
207
|
+
- 0
|
208
|
+
version: "0"
|
209
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
210
|
none: false
|
93
|
-
requirements:
|
94
|
-
- -
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
|
211
|
+
requirements:
|
212
|
+
- - ">="
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
hash: 3
|
215
|
+
segments:
|
216
|
+
- 0
|
217
|
+
version: "0"
|
97
218
|
requirements: []
|
219
|
+
|
98
220
|
rubyforge_project: inboxes
|
99
|
-
rubygems_version: 1.8.
|
221
|
+
rubygems_version: 1.8.11
|
100
222
|
signing_key:
|
101
223
|
specification_version: 3
|
102
224
|
summary: Messaging system for Rails 3 app
|
103
|
-
test_files:
|
225
|
+
test_files:
|
226
|
+
- spec/devise_config.rb
|
227
|
+
- spec/fake_app.rb
|
228
|
+
- spec/fake_gem.rb
|
229
|
+
- spec/inboxes/discussion_spec.rb
|
230
|
+
- spec/inboxes/discussions_controller_spec.rb
|
231
|
+
- spec/inboxes/discussions_routing_spec.rb
|
232
|
+
- spec/inboxes/message_spec.rb
|
233
|
+
- spec/inboxes/messages_controller_spec.rb
|
234
|
+
- spec/inboxes/speaker_spec.rb
|
235
|
+
- spec/inboxes/speakers_controller_spec.rb
|
236
|
+
- spec/inboxes_spec.rb
|
237
|
+
- spec/spec_helper.rb
|
238
|
+
- spec/support/factories.rb
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# Implementation class for Cancan gem. Instead of overriding this class, consider adding new permissions
|
2
|
-
# using the special +register_ability+ method which allows extensions to add their own abilities.
|
3
|
-
#
|
4
|
-
# See http://github.com/ryanb/cancan for more details on cancan.
|
5
|
-
module Inboxes
|
6
|
-
class Ability
|
7
|
-
include CanCan::Ability
|
8
|
-
|
9
|
-
class_attribute :abilities
|
10
|
-
self.abilities = Set.new
|
11
|
-
|
12
|
-
# Allows us to go beyond the standard cancan initialize method which makes it difficult for engines to
|
13
|
-
# modify the default +Ability+ of an application. The +ability+ argument must be a class that includes
|
14
|
-
# the +CanCan::Ability+ module. The registered ability should behave properly as a stand-alone class
|
15
|
-
# and therefore should be easy to test in isolation.
|
16
|
-
def self.register_ability(ability)
|
17
|
-
self.abilities.add(ability)
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize(user)
|
22
|
-
# raise "Initializing 3rd patry"
|
23
|
-
# self.clear_aliased_actions
|
24
|
-
|
25
|
-
# can [:index, :create], Discussion
|
26
|
-
# can :read, Discussion do |discussion|
|
27
|
-
# discussion.can_participate?(user)
|
28
|
-
# end
|
29
|
-
|
30
|
-
#include any abilities registered by extensions, etc.
|
31
|
-
|
32
|
-
Ability.abilities.each do |clazz|
|
33
|
-
ability = clazz.send(:new, user)
|
34
|
-
@rules = rules + ability.send(:rules)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/lib/inboxes/ability.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require "cancan"
|
2
|
-
|
3
|
-
module Inboxes
|
4
|
-
class InboxesAbility
|
5
|
-
include ::CanCan::Ability
|
6
|
-
|
7
|
-
def initialize(user)
|
8
|
-
# Discussion
|
9
|
-
# raise "Registered!"
|
10
|
-
if user
|
11
|
-
can [:index, :create], Discussion
|
12
|
-
can :read, Discussion do |discussion|
|
13
|
-
discussion.can_participate?(user)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# Message
|
18
|
-
# can :create, Message do |message|
|
19
|
-
# message.discussion.can_participate?(user)
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# # Speaker
|
23
|
-
# can [:create, :destroy], Speaker do |speaker|
|
24
|
-
# speaker.discussion.can_participate?(user)
|
25
|
-
# end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|