Skip to content

Commit

Permalink
Remove unused code and add specs for #open?
Browse files Browse the repository at this point in the history
According to coveralls some parts of code is not longer used. I added
specs for untested code.
  • Loading branch information
LTe committed Jun 9, 2019
1 parent 3860a54 commit f84d7cb
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.4.0)
ancestry (3.0.6)
ancestry (3.0.7)
activerecord (>= 3.2.0)
appraisal (2.2.0)
bundler
Expand Down
9 changes: 2 additions & 7 deletions lib/acts-as-messageable/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,8 @@ def acts_as_messageable(options = {})
self.messages_class_name = options[:class_name].constantize
messages_class_name.has_ancestry

if messages_class_name.respond_to?(:table_name=)
messages_class_name.table_name = options[:table_name]
messages_class_name.initialize_scopes
else
messages_class_name.set_table_name(options[:table_name])
ActiveSupport::Deprecation.warn("Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead.")
end
messages_class_name.table_name = options[:table_name]
messages_class_name.initialize_scopes

messages_class_name.required = Array.wrap(options[:required])
messages_class_name.validates_presence_of messages_class_name.required
Expand Down
4 changes: 0 additions & 4 deletions lib/acts-as-messageable/rails3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ def initialize(subject)
@subject = subject
end

def attr_accessible(*args)
@subject.attr_accessible(*args)
end

def default_scope(order_by)
@subject.send(:default_scope, order(order_by))
end
Expand Down
4 changes: 0 additions & 4 deletions lib/acts-as-messageable/rails4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ def initialize(subject)
@subject = subject
end

def attr_accessible(*args)
@subject.attr_accessible(*args) if defined?(ProtectedAttributes)
end

def default_scope(order_by)
@subject.send(:default_scope) { order(order_by) }
end
Expand Down
1 change: 1 addition & 0 deletions spec/acts-as-messageable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
it 'alice should have one unread message from bob' do
expect(@alice.messages.are_from(@bob).unreaded.count).to eq(1)
expect(@alice.messages.are_from(@bob).readed.count).to eq(0)
expect(@alice.messages.are_from(@bob).readed.all? { |message| message.open? }).to be_truthy
end

it 'alice should able to read message from bob' do
Expand Down

0 comments on commit f84d7cb

Please sign in to comment.