acts_as_status_for 2.1.0 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/acts_as_status_for.gemspec +1 -1
- data/lib/acts_as_status_for.rb +29 -0
- data/spec/acts_as_status_for_spec.rb +26 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.3
|
data/acts_as_status_for.gemspec
CHANGED
data/lib/acts_as_status_for.rb
CHANGED
@@ -98,6 +98,35 @@ module ActsAsStatusFor
|
|
98
98
|
end
|
99
99
|
|
100
100
|
module InstanceMethods
|
101
|
+
def status_including_method(method)
|
102
|
+
if method =~ /status_including_(.+)/
|
103
|
+
$1
|
104
|
+
else
|
105
|
+
nil
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def respond_to_missing?(method,include_private)
|
110
|
+
! status_including_method(method).nil?
|
111
|
+
end
|
112
|
+
|
113
|
+
def statuses_including(status_list)
|
114
|
+
has_condition = self.class
|
115
|
+
status_list.each do |state|
|
116
|
+
has_condition = has_condition.where(self.class.arel_table["#{state}_at".to_sym].not_eq(nil))
|
117
|
+
end
|
118
|
+
has_condition
|
119
|
+
end
|
120
|
+
|
121
|
+
def method_missing(method,*rest,&block)
|
122
|
+
includes = status_including_method(method)
|
123
|
+
if not includes.blank?
|
124
|
+
statuses_including(includes.split('_and_'))
|
125
|
+
else
|
126
|
+
super
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
101
130
|
def current_status
|
102
131
|
status.split(' ').first or ''
|
103
132
|
end
|
@@ -78,7 +78,32 @@ describe ActsAsStatusFor do
|
|
78
78
|
subject.current_status.should == ''
|
79
79
|
end
|
80
80
|
end
|
81
|
-
|
81
|
+
context "#status_including_" do
|
82
|
+
it "#respond_to? :status_including_archived" do
|
83
|
+
subject.respond_to? :status_including_archived
|
84
|
+
end
|
85
|
+
it "archived" do
|
86
|
+
subject.status_including_archived.should_not include(subject)
|
87
|
+
subject.archived!
|
88
|
+
subject.status_including_archived.should include(subject)
|
89
|
+
end
|
90
|
+
it "archived_and_featured" do
|
91
|
+
subject.status_including_archived_and_featured.should_not include(subject)
|
92
|
+
subject.archived!
|
93
|
+
subject.status_including_archived_and_featured.should_not include(subject)
|
94
|
+
subject.featured!
|
95
|
+
subject.status_including_archived_and_featured.should include(subject)
|
96
|
+
end
|
97
|
+
it "archived_and_featured_and_on_hold" do
|
98
|
+
subject.status_including_archived_and_featured_and_on_hold.should_not include(subject)
|
99
|
+
subject.archived!
|
100
|
+
subject.status_including_archived_and_featured_and_on_hold.should_not include(subject)
|
101
|
+
subject.featured!
|
102
|
+
subject.status_including_archived_and_featured_and_on_hold.should_not include(subject)
|
103
|
+
subject.on_hold!
|
104
|
+
subject.status_including_archived_and_featured_and_on_hold.should include(subject)
|
105
|
+
end
|
106
|
+
end
|
82
107
|
context "#status" do
|
83
108
|
before do
|
84
109
|
Thing.instance_eval do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: acts_as_status_for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version:
|
5
|
+
version: 3.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Curtis Schofield
|
@@ -116,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
116
|
requirements:
|
117
117
|
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
hash:
|
119
|
+
hash: 550898432098812955
|
120
120
|
segments:
|
121
121
|
- 0
|
122
122
|
version: "0"
|