delayed_job_active_record 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +1 -4
- data/lib/delayed/backend/active_record.rb +6 -3
- data/lib/delayed_job_active_record.rb +1 -1
- data/lib/generators/delayed_job/active_record_generator.rb +3 -3
- data/lib/generators/delayed_job/templates/migration.rb +4 -4
- data/spec/database.yml +1 -1
- data/spec/delayed/backend/active_record_spec.rb +16 -1
- data/spec/delayed/serialization/active_record_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +4 -4
data/LICENSE
CHANGED
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOa AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SaALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
# DelayedJob ActiveRecord Backend
|
2
2
|
|
3
|
-
Please note! This is a pre-release version intended for use only with DelayedJob 3.0
|
4
|
-
|
5
3
|
## Installation
|
6
4
|
|
7
5
|
Add the gems to your Gemfile:
|
8
6
|
|
9
|
-
gem 'delayed_job'
|
10
7
|
gem 'delayed_job_active_record'
|
11
8
|
|
12
9
|
Run `bundle install`
|
13
10
|
|
14
11
|
If you're using Rails, run the generator to create the migration for the delayed_job table: `rails g delayed_job:active_record`
|
15
12
|
|
16
|
-
That's it. Use [delayed_job as normal](http://github.com/collectiveidea/delayed_job).
|
13
|
+
That's it. Use [delayed_job as normal](http://github.com/collectiveidea/delayed_job).
|
@@ -9,12 +9,15 @@ module Delayed
|
|
9
9
|
include Delayed::Backend::Base
|
10
10
|
set_table_name :delayed_jobs
|
11
11
|
|
12
|
+
attr_accessible :priority, :run_at, :queue, :payload_object,
|
13
|
+
:failed_at, :locked_at, :locked_by
|
14
|
+
|
12
15
|
before_save :set_default_run_at
|
13
|
-
|
16
|
+
|
14
17
|
def self.rails3?
|
15
18
|
::ActiveRecord::VERSION::MAJOR == 3
|
16
19
|
end
|
17
|
-
|
20
|
+
|
18
21
|
if rails3?
|
19
22
|
scope :ready_to_run, lambda{|worker_name, max_run_time|
|
20
23
|
where('(run_at <= ? AND (locked_at IS NULL OR locked_at < ?) OR locked_by = ?) AND failed_at IS NULL', db_time_now, db_time_now - max_run_time, worker_name)
|
@@ -87,7 +90,7 @@ module Delayed
|
|
87
90
|
Time.now
|
88
91
|
end
|
89
92
|
end
|
90
|
-
|
93
|
+
|
91
94
|
def reload(*args)
|
92
95
|
reset
|
93
96
|
super
|
@@ -7,11 +7,11 @@ module DelayedJob
|
|
7
7
|
class ActiveRecordGenerator < ::DelayedJobGenerator
|
8
8
|
include Rails::Generators::Migration
|
9
9
|
extend ActiveRecord::Generators::Migration
|
10
|
-
|
10
|
+
|
11
11
|
self.source_paths << File.join(File.dirname(__FILE__), 'templates')
|
12
|
-
|
12
|
+
|
13
13
|
def create_migration_file
|
14
14
|
migration_template 'migration.rb', 'db/migrate/create_delayed_jobs.rb'
|
15
15
|
end
|
16
16
|
end
|
17
|
-
end
|
17
|
+
end
|
@@ -12,11 +12,11 @@ class CreateDelayedJobs < ActiveRecord::Migration
|
|
12
12
|
table.string :queue # The name of the queue this job is in
|
13
13
|
table.timestamps
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def self.down
|
20
|
-
drop_table :delayed_jobs
|
20
|
+
drop_table :delayed_jobs
|
21
21
|
end
|
22
|
-
end
|
22
|
+
end
|
data/spec/database.yml
CHANGED
@@ -33,7 +33,7 @@ describe Delayed::Backend::ActiveRecord::Job do
|
|
33
33
|
Delayed::Backend::ActiveRecord::Job.after_fork
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
describe "enqueue" do
|
38
38
|
it "should allow enqueue hook to modify job at DB level" do
|
39
39
|
later = described_class.db_time_now + 20.minutes
|
@@ -41,4 +41,19 @@ describe Delayed::Backend::ActiveRecord::Job do
|
|
41
41
|
Delayed::Backend::ActiveRecord::Job.find(job.id).run_at.should be_within(1).of(later)
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
context "ActiveRecord::Base.send(:attr_accessible, nil)" do
|
46
|
+
before do
|
47
|
+
Delayed::Backend::ActiveRecord::Job.send(:attr_accessible, nil)
|
48
|
+
end
|
49
|
+
|
50
|
+
after do
|
51
|
+
Delayed::Backend::ActiveRecord::Job.send(:attr_accessible, *Delayed::Backend::ActiveRecord::Job.new.attributes.keys)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should still be accessible" do
|
55
|
+
job = Delayed::Backend::ActiveRecord::Job.enqueue :payload_object => EnqueueJobMod.new
|
56
|
+
Delayed::Backend::ActiveRecord::Job.find(job.id).handler.should_not be_blank
|
57
|
+
end
|
58
|
+
end
|
44
59
|
end
|
@@ -4,12 +4,12 @@ describe ActiveRecord do
|
|
4
4
|
it 'should load classes with non-default primary key' do
|
5
5
|
lambda {
|
6
6
|
YAML.load(Story.create.to_yaml)
|
7
|
-
}.should_not raise_error
|
7
|
+
}.should_not raise_error
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'should load classes even if not in default scope' do
|
11
11
|
lambda {
|
12
12
|
YAML.load(Story.create(:scoped => false).to_yaml)
|
13
|
-
}.should_not raise_error
|
13
|
+
}.should_not raise_error
|
14
14
|
end
|
15
15
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayed_job_active_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Griffin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-30 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|