rivendell-import 1.02 → 1.03

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rivendell-import (1.02)
4
+ rivendell-import (1.03)
5
5
  SyslogLogger (~> 2.0)
6
6
  activerecord (~> 3.2.8)
7
7
  activesupport (~> 3.2.8)
@@ -51,7 +51,7 @@ GEM
51
51
  gherkin (~> 2.12)
52
52
  multi_json (>= 1.7.5, < 2.0)
53
53
  multi_test (>= 0.1.1)
54
- daemons (1.1.9)
54
+ daemons (1.2.2)
55
55
  data_objects (0.10.15)
56
56
  addressable (~> 2.1)
57
57
  database_cleaner (1.3.0)
@@ -184,7 +184,7 @@ GEM
184
184
  taglib-ruby (0.7.0)
185
185
  thor (0.19.1)
186
186
  tilt (1.4.1)
187
- trollop (2.1.1)
187
+ trollop (2.1.2)
188
188
  tzinfo (0.3.43)
189
189
  uuidtools (2.1.5)
190
190
  will_paginate (3.0.7)
@@ -37,3 +37,7 @@ end
37
37
  Then /^the task should have tag "([^"]*)"$/ do |tag|
38
38
  import.tasks.pop.tags.should include(tag)
39
39
  end
40
+
41
+ Then /^the task should have status "([^"]*)"$/ do |status|
42
+ Rivendell::Import::Task.last.status.should == status
43
+ end
@@ -63,6 +63,7 @@ module Rivendell::Import
63
63
  Context.new(self).run(&block)
64
64
  rescue => e
65
65
  logger.error "Task preparation failed : #{e}"
66
+ change_status! :failed
66
67
  end
67
68
  self
68
69
  end
@@ -133,7 +134,7 @@ module Rivendell::Import
133
134
  logger.debug e.backtrace.join("\n")
134
135
  ensure
135
136
  close_file
136
-
137
+
137
138
  unless ran?
138
139
  change_status! :failed
139
140
  end
@@ -22,9 +22,15 @@ module Rivendell::Import::Tasking
22
22
 
23
23
  def change_status!(status)
24
24
  logger.debug "Change status to #{status}"
25
- update_attribute :status, status.to_s
25
+ if persisted?
26
+ update_attribute :status, status.to_s
27
+ else
28
+ self.status = status.to_s
29
+ end
26
30
  # notify! if ran?
27
31
  invoke_status_changed_callbacks
32
+
33
+ self
28
34
  end
29
35
 
30
36
  def invoke_status_changed_callbacks
@@ -1,5 +1,5 @@
1
1
  module Rivendell
2
2
  module Import
3
- VERSION = "1.02"
3
+ VERSION = "1.03"
4
4
  end
5
5
  end
@@ -63,6 +63,13 @@ describe Rivendell::Import::Task do
63
63
  given_file.should == subject.file
64
64
  end
65
65
 
66
+ it "should change task status to failed if prepare fails" do
67
+ subject.prepare do |file|
68
+ raise "Error"
69
+ end
70
+ subject.status.should == "failed"
71
+ end
72
+
66
73
  end
67
74
 
68
75
  describe "#run" do
@@ -252,8 +259,8 @@ describe Rivendell::Import::Task do
252
259
  describe "#change_status!" do
253
260
 
254
261
  it "should update_attribute :status" do
255
- subject.should_receive(:update_attribute).with(:status, "completed")
256
262
  subject.change_status! :completed
263
+ subject.status.should == "completed"
257
264
  end
258
265
 
259
266
  it "should notify change when status is completed" do
@@ -344,17 +351,17 @@ describe Rivendell::Import::Task do
344
351
  describe ".ran" do
345
352
 
346
353
  it "should return completed tasks" do
347
- subject.change_status! "completed"
354
+ subject.change_status!("completed").save
348
355
  expect(Rivendell::Import::Task.ran).to include(subject)
349
356
  end
350
357
 
351
358
  it "should return failed tasks" do
352
- subject.change_status! "failed"
359
+ subject.change_status!("failed").save
353
360
  expect(Rivendell::Import::Task.ran).to include(subject)
354
361
  end
355
362
 
356
363
  it "should return canceled tasks" do
357
- subject.change_status! "canceled"
364
+ subject.change_status!("canceled").save
358
365
  expect(Rivendell::Import::Task.ran).to include(subject)
359
366
  end
360
367
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rivendell-import
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.02'
4
+ version: '1.03'
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: 2015-02-25 00:00:00.000000000 Z
12
+ date: 2015-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: listen
@@ -503,7 +503,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
503
503
  version: '0'
504
504
  segments:
505
505
  - 0
506
- hash: 2132046489375508529
506
+ hash: 3840553868177619647
507
507
  required_rubygems_version: !ruby/object:Gem::Requirement
508
508
  none: false
509
509
  requirements:
@@ -512,7 +512,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
512
512
  version: '0'
513
513
  segments:
514
514
  - 0
515
- hash: 2132046489375508529
515
+ hash: 3840553868177619647
516
516
  requirements: []
517
517
  rubyforge_project:
518
518
  rubygems_version: 1.8.23