acts-as-approvable 0.6.7 → 0.6.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -5
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Appraisals +14 -10
- data/CHANGELOG +16 -0
- data/Gemfile.lock +60 -20
- data/README.md +1 -2
- data/Rakefile +44 -16
- data/VERSION +1 -1
- data/acts-as-approvable.gemspec +21 -11
- data/features/create_approval.feature +26 -0
- data/features/step_definitions/cucumber_steps.rb +86 -0
- data/features/support/env.rb +14 -0
- data/features/support/large.txt +29943 -0
- data/features/support/second_large.txt +31798 -0
- data/features/update_approval.feature +34 -0
- data/gemfiles/Gemfile.ci +14 -0
- data/gemfiles/Gemfile.ci.lock +98 -0
- data/gemfiles/mysql2.gemfile +7 -0
- data/gemfiles/mysql2.gemfile.lock +92 -0
- data/gemfiles/rails2.gemfile +1 -0
- data/gemfiles/rails2.gemfile.lock +59 -17
- data/gemfiles/rails30.gemfile +1 -0
- data/gemfiles/rails30.gemfile.lock +54 -14
- data/gemfiles/rails31.gemfile +1 -0
- data/gemfiles/rails31.gemfile.lock +54 -14
- data/gemfiles/sqlite.gemfile +7 -0
- data/generators/acts_as_approvable/templates/create_approvals.rb +8 -7
- data/lib/acts-as-approvable.rb +2 -3
- data/lib/acts_as_approvable/approval.rb +3 -2
- data/lib/acts_as_approvable/model.rb +55 -0
- data/lib/acts_as_approvable/model/class_methods.rb +63 -0
- data/lib/acts_as_approvable/model/create_instance_methods.rb +83 -0
- data/lib/acts_as_approvable/model/instance_methods.rb +89 -0
- data/lib/acts_as_approvable/model/update_instance_methods.rb +61 -0
- data/lib/acts_as_approvable/railtie.rb +1 -1
- data/lib/generators/acts_as_approvable/templates/create_approvals.rb +8 -7
- data/spec/acts_as_approvable/approval_spec.rb +475 -0
- data/spec/acts_as_approvable/model/class_methods_spec.rb +219 -0
- data/spec/acts_as_approvable/model/create_instance_methods_spec.rb +149 -0
- data/spec/acts_as_approvable/model/instance_methods_spec.rb +328 -0
- data/spec/acts_as_approvable/model/update_instance_methods_spec.rb +111 -0
- data/spec/acts_as_approvable/model_spec.rb +90 -0
- data/spec/acts_as_approvable/ownership/class_methods_spec.rb +101 -0
- data/spec/acts_as_approvable/ownership/instance_methods_spec.rb +32 -0
- data/spec/acts_as_approvable/ownership_spec.rb +51 -0
- data/spec/acts_as_approvable_spec.rb +29 -0
- data/spec/spec_helper.rb +51 -0
- data/spec/support/database.rb +46 -0
- data/spec/support/database.yml +12 -0
- data/spec/support/matchers.rb +87 -0
- data/spec/support/models.rb +60 -0
- data/{test → spec/support}/schema.rb +15 -9
- metadata +156 -53
- data/gemfiles/rails32.gemfile +0 -8
- data/gemfiles/rails32.gemfile.lock +0 -99
- data/lib/acts_as_approvable/acts_as_approvable.rb +0 -291
- data/test/acts_as_approvable_model_test.rb +0 -459
- data/test/acts_as_approvable_ownership_test.rb +0 -132
- data/test/acts_as_approvable_schema_test.rb +0 -13
- data/test/acts_as_approvable_test.rb +0 -8
- data/test/database.yml +0 -7
- data/test/support.rb +0 -19
- data/test/test_helper.rb +0 -62
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Appraisals
CHANGED
@@ -1,18 +1,22 @@
|
|
1
1
|
appraise 'rails2' do
|
2
2
|
gem 'activerecord', '~> 2.3'
|
3
|
+
gem 'sqlite3'
|
3
4
|
end
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
if RUBY_VERSION =~ /^1\.9/
|
7
|
+
appraise 'rails30' do
|
8
|
+
gem 'activerecord', '~> 3.0.0'
|
9
|
+
gem 'railties', '~> 3.0.0'
|
10
|
+
gem 'sqlite3'
|
11
|
+
end
|
9
12
|
|
10
|
-
appraise 'rails31' do
|
11
|
-
|
12
|
-
|
13
|
+
appraise 'rails31' do
|
14
|
+
gem 'activerecord', '~> 3.1.0'
|
15
|
+
gem 'railties', '~> 3.1.0'
|
16
|
+
gem 'sqlite3'
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
|
-
appraise '
|
16
|
-
gem '
|
17
|
-
gem 'railties', '~> 3.2.0'
|
20
|
+
appraise 'mysql2' do
|
21
|
+
gem 'mysql2', '~> 0.2.18'
|
18
22
|
end
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
== 0.6.8.1
|
2
|
+
|
3
|
+
* Bad gem push...
|
4
|
+
|
5
|
+
== 0.6.8
|
6
|
+
|
7
|
+
* Fixed issue where approval state would be checked if the local state field
|
8
|
+
was present but not the value being checked.
|
9
|
+
* Reorganized `ActsAsApprovable::Model` into seperate files.
|
10
|
+
* `.acts_as_approvable` is the only method that should be available until
|
11
|
+
called. Moved other class methods into a module that is included on
|
12
|
+
configuration.
|
13
|
+
* Moved from Test::Unit to RSpec
|
14
|
+
* Renamed `can_save?` to `able_to_save?`
|
15
|
+
* Specify larger field size for original and object columns (16MB)
|
16
|
+
|
1
17
|
== 0.6.6
|
2
18
|
|
3
19
|
* `#pending_changes?` should not be true if there are no pending update
|
data/Gemfile.lock
CHANGED
@@ -12,39 +12,79 @@ GEM
|
|
12
12
|
appraisal (0.4.1)
|
13
13
|
bundler
|
14
14
|
rake
|
15
|
+
binding_of_caller (0.6.7)
|
16
|
+
builder (3.0.0)
|
15
17
|
coderay (1.0.5)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
coolline (0.1.0)
|
19
|
+
cucumber (1.1.0)
|
20
|
+
builder (>= 2.1.2)
|
21
|
+
diff-lcs (>= 1.1.2)
|
22
|
+
gherkin (~> 2.5.0)
|
23
|
+
json (>= 1.4.6)
|
24
|
+
term-ansicolor (>= 1.0.6)
|
25
|
+
diff-lcs (1.1.3)
|
26
|
+
gherkin (2.5.1)
|
27
|
+
json (>= 1.4.6)
|
28
|
+
io-console (0.3)
|
29
|
+
json (1.6.5)
|
30
|
+
method_source (0.7.1)
|
31
|
+
multi_json (1.1.0)
|
32
|
+
plymouth (0.3.2)
|
33
|
+
pry-exception_explorer (>= 0.1.7)
|
34
|
+
pry (0.9.8.4)
|
22
35
|
coderay (~> 1.0.5)
|
23
|
-
method_source (~> 0.7)
|
24
|
-
slop (>= 2.4.
|
36
|
+
method_source (~> 0.7.1)
|
37
|
+
slop (>= 2.4.4, < 3)
|
38
|
+
pry-coolline (0.1.1)
|
39
|
+
coolline (~> 0.1.0)
|
40
|
+
io-console (~> 0.3.0)
|
41
|
+
pry-exception_explorer (0.1.9)
|
42
|
+
pry-stack_explorer (>= 0.3.9)
|
43
|
+
pry-nav (0.1.0)
|
44
|
+
pry (~> 0.9.8.1)
|
45
|
+
pry-stack_explorer (0.4.1)
|
46
|
+
binding_of_caller (~> 0.6.2)
|
47
|
+
pry (~> 0.9.8.2)
|
48
|
+
pry-syntax-hacks (0.0.6)
|
49
|
+
pry (>= 0.9.8)
|
25
50
|
rake (0.9.2.2)
|
26
51
|
redcarpet (2.1.0)
|
52
|
+
rspec (2.8.0)
|
53
|
+
rspec-core (~> 2.8.0)
|
54
|
+
rspec-expectations (~> 2.8.0)
|
55
|
+
rspec-mocks (~> 2.8.0)
|
56
|
+
rspec-core (2.8.0)
|
57
|
+
rspec-expectations (2.8.0)
|
58
|
+
diff-lcs (~> 1.1.2)
|
59
|
+
rspec-mocks (2.8.0)
|
27
60
|
shoulda (2.11.3)
|
28
|
-
simplecov (0.
|
29
|
-
multi_json (~> 1.0
|
61
|
+
simplecov (0.6.1)
|
62
|
+
multi_json (~> 1.0)
|
30
63
|
simplecov-html (~> 0.5.3)
|
31
64
|
simplecov-html (0.5.3)
|
32
|
-
slop (2.4.
|
33
|
-
|
65
|
+
slop (2.4.4)
|
66
|
+
term-ansicolor (1.0.6)
|
67
|
+
timecop (0.3.5)
|
34
68
|
yard (0.7.5)
|
35
69
|
|
36
70
|
PLATFORMS
|
37
71
|
ruby
|
38
72
|
|
39
73
|
DEPENDENCIES
|
40
|
-
activerecord (~> 2.3)
|
74
|
+
activerecord (~> 2.3.14)
|
41
75
|
acts-as-approvable!
|
42
|
-
appraisal
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
76
|
+
appraisal (~> 0.4.1)
|
77
|
+
cucumber (~> 1.1.0)
|
78
|
+
plymouth
|
79
|
+
pry (~> 0.9.8.1)
|
80
|
+
pry-coolline
|
81
|
+
pry-nav (~> 0.1.0)
|
82
|
+
pry-stack_explorer
|
83
|
+
pry-syntax-hacks
|
84
|
+
rake (~> 0.9.2)
|
85
|
+
redcarpet (~> 2.1.0)
|
86
|
+
rspec (~> 2.8.0)
|
87
|
+
shoulda (~> 2.0)
|
48
88
|
simplecov
|
49
|
-
|
89
|
+
timecop (~> 0.3.5)
|
50
90
|
yard
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
Acts as Approvable
|
2
|
-
==================
|
1
|
+
# Acts as Approvable [![Build Status](https://secure.travis-ci.org/jlogsdon/acts_as_approvable.png)](http://travis-ci.org/jlogsdon/acts_as_approvable?branch=master)
|
3
2
|
|
4
3
|
This plugin provides a workflow for approving new records and changes to existing
|
5
4
|
records.
|
data/Rakefile
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
3
|
require 'rake/testtask'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'cucumber'
|
6
|
+
require 'cucumber/rake/task'
|
4
7
|
require 'yard'
|
5
8
|
require 'appraisal'
|
6
9
|
|
@@ -11,12 +14,12 @@ desc 'Start a pry session with a database connection open'
|
|
11
14
|
task :pry do |t|
|
12
15
|
$LOAD_PATH << './lib'
|
13
16
|
require 'pry'
|
14
|
-
require './
|
17
|
+
require './spec/spec_helper'
|
15
18
|
|
16
|
-
|
17
|
-
load_schema
|
19
|
+
Support::Database.setup_log(STDOUT)
|
20
|
+
Support::Database.load_schema
|
18
21
|
|
19
|
-
ActsAsApprovable::Ownership.configure
|
22
|
+
#ActsAsApprovable::Ownership.configure
|
20
23
|
Pry.start(TOPLEVEL_BINDING)
|
21
24
|
end
|
22
25
|
|
@@ -33,20 +36,19 @@ task :copy do |t|
|
|
33
36
|
end
|
34
37
|
|
35
38
|
desc 'Test the acts_as_approvable plugin.'
|
36
|
-
|
37
|
-
t.libs << 'test' << 'lib'
|
38
|
-
t.pattern = 'test/*_test.rb'
|
39
|
-
t.verbose = true
|
40
|
-
end
|
39
|
+
RSpec::Core::RakeTask.new(:test)
|
41
40
|
|
42
41
|
if RUBY_VERSION =~ /^1\.8/
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
begin
|
43
|
+
require 'rcov/rcovtask'
|
44
|
+
Rcov::RcovTask.new do |t|
|
45
|
+
t.libs << 'test' << 'lib'
|
46
|
+
t.rcov_opts << '--exclude' << '"Library/Ruby/*"' << '--sort' << 'coverage'
|
47
|
+
t.pattern = 'test/*_test.rb'
|
48
|
+
t.output_dir = 'coverage/'
|
49
|
+
t.verbose = true
|
50
|
+
end
|
51
|
+
rescue LoadError
|
50
52
|
end
|
51
53
|
elsif RUBY_VERSION =~ /^1\.9/
|
52
54
|
namespace :test do
|
@@ -57,6 +59,32 @@ elsif RUBY_VERSION =~ /^1\.9/
|
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
62
|
+
namespace :test do
|
63
|
+
desc 'Setup appraisals and install gems for the gambit run'
|
64
|
+
task :setup do
|
65
|
+
start = Time.now
|
66
|
+
Kernel.system('rbenv each -v bundle install')
|
67
|
+
Kernel.system('rbenv each -v bundle exec rake appraisal:install')
|
68
|
+
elapsed = Time.now - start
|
69
|
+
|
70
|
+
puts "\nRan everything in #{elapsed} seconds"
|
71
|
+
end
|
72
|
+
|
73
|
+
desc 'Run all specs and features across all installed rubies'
|
74
|
+
task :gambit do
|
75
|
+
start = Time.now
|
76
|
+
Kernel.system('rbenv each -v bundle exec rake appraisal test')
|
77
|
+
Kernel.system('rbenv each -v bundle exec rake appraisal features')
|
78
|
+
elapsed = Time.now - start
|
79
|
+
|
80
|
+
puts "\nRan everything in #{elapsed} seconds"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
85
|
+
t.cucumber_opts = "features --format pretty"
|
86
|
+
end
|
87
|
+
|
60
88
|
desc 'Generate documentation for the acts_as_approvable plugin.'
|
61
89
|
YARD::Rake::YardocTask.new do |t|
|
62
90
|
yard_dir = (ENV['YARD_DIR'] || 'yardoc')
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.8.1
|
data/acts-as-approvable.gemspec
CHANGED
@@ -14,18 +14,28 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.date = %q(2012-02-14)
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
|
-
s.test_files = `git ls-files --
|
17
|
+
s.test_files = `git ls-files -- spec/* features/*`.split("\n")
|
18
18
|
s.require_paths = ['lib']
|
19
19
|
|
20
|
-
s.add_development_dependency %q<activerecord>,
|
21
|
-
s.add_development_dependency %q<appraisal
|
22
|
-
s.add_development_dependency %q<redcarpet
|
23
|
-
s.add_development_dependency %q<shoulda
|
24
|
-
s.add_development_dependency %q<
|
25
|
-
s.add_development_dependency %q<
|
26
|
-
s.add_development_dependency %q<
|
27
|
-
s.add_development_dependency %q<
|
28
|
-
s.add_development_dependency %q<simplecov> if RUBY_VERSION =~ /^1\.9/
|
20
|
+
s.add_development_dependency %q<activerecord>, '~> 2.3.14'
|
21
|
+
s.add_development_dependency %q<appraisal>, '~> 0.4.1'
|
22
|
+
s.add_development_dependency %q<redcarpet>, '~> 2.1.0'
|
23
|
+
s.add_development_dependency %q<shoulda>, '~> 2.0'
|
24
|
+
s.add_development_dependency %q<rspec>, '~> 2.8.0'
|
25
|
+
s.add_development_dependency %q<timecop>, '~> 0.3.5'
|
26
|
+
s.add_development_dependency %q<cucumber>, '~> 1.1.0'
|
27
|
+
s.add_development_dependency %q<rake>, '~> 0.9.2'
|
29
28
|
s.add_development_dependency %q<yard>
|
30
|
-
s.add_development_dependency %q<pry
|
29
|
+
s.add_development_dependency %q<pry>, '~> 0.9.8.1'
|
30
|
+
s.add_development_dependency %q<pry-syntax-hacks>
|
31
|
+
|
32
|
+
if RUBY_VERSION =~ /^1\.9/
|
33
|
+
s.add_development_dependency %q<simplecov>
|
34
|
+
s.add_development_dependency %q<pry-coolline>
|
35
|
+
s.add_development_dependency %q<pry-stack_explorer>
|
36
|
+
s.add_development_dependency %q<pry-nav>, '~> 0.1.0'
|
37
|
+
s.add_development_dependency %q<plymouth>
|
38
|
+
elsif RUBY_VERSION =~ /^1\.8/
|
39
|
+
s.add_development_dependency %q<rcov>
|
40
|
+
end
|
31
41
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Feature: Create Approvals
|
2
|
+
In order to provide an approval queue for new records
|
3
|
+
|
4
|
+
Background:
|
5
|
+
Given a record created with create approval
|
6
|
+
|
7
|
+
Scenario: a new record is created
|
8
|
+
Then it should be pending
|
9
|
+
|
10
|
+
Scenario: a new record is approved
|
11
|
+
When I approve the record
|
12
|
+
Then it should be approved
|
13
|
+
|
14
|
+
Scenario: a new record is rejected
|
15
|
+
When I reject the record
|
16
|
+
Then it should be rejected
|
17
|
+
|
18
|
+
Scenario: an approved record is approved again
|
19
|
+
When the record is already approved
|
20
|
+
And I approve the record
|
21
|
+
Then it should raise ActsAsApprovable::Error::Locked
|
22
|
+
|
23
|
+
Scenario: an approved record is rejected
|
24
|
+
When the record is already approved
|
25
|
+
And I reject the record
|
26
|
+
Then it should raise ActsAsApprovable::Error::Locked
|
@@ -0,0 +1,86 @@
|
|
1
|
+
def support_file_path(file)
|
2
|
+
File.join('features', 'support', file.gsub(/^file:/, '').gsub(/ +/, '_') + '.txt')
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^a record created with (create|update|any) approval$/ do |type|
|
6
|
+
@record = case type
|
7
|
+
when 'create'; CreatesApprovable.create
|
8
|
+
when 'update'; UpdatesApprovable.create
|
9
|
+
when 'any'; DefaultApprovable.create
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^I (approve|reject) the (record|changes?)$/ do |state, type|
|
14
|
+
begin
|
15
|
+
method = "#{state}!".to_sym
|
16
|
+
|
17
|
+
case type
|
18
|
+
when 'record'; @record.send(method)
|
19
|
+
when 'changes', 'change'; @approval.send(method)
|
20
|
+
end
|
21
|
+
rescue => @last_error
|
22
|
+
end
|
23
|
+
|
24
|
+
@record.reload
|
25
|
+
end
|
26
|
+
|
27
|
+
When /^the record is already (approved|rejected)$/ do |state|
|
28
|
+
case state
|
29
|
+
when 'approved'; @record.approve!
|
30
|
+
when 'rejected'; @record.reject!
|
31
|
+
end
|
32
|
+
|
33
|
+
@record.reload
|
34
|
+
end
|
35
|
+
|
36
|
+
When /^I update the record with:$/ do |table|
|
37
|
+
table.rows_hash.each_pair do |attr, value|
|
38
|
+
value = File.read(support_file_path(value)) if value =~ /^file:/
|
39
|
+
@record[attr] = value
|
40
|
+
end
|
41
|
+
@record.save!
|
42
|
+
|
43
|
+
@approval = @record.update_approvals.last
|
44
|
+
@update = table.rows_hash
|
45
|
+
end
|
46
|
+
|
47
|
+
Then /^it should be (pending|approved|rejected)$/ do |state|
|
48
|
+
method = "#{state}?".to_sym
|
49
|
+
@record.send(method).should be_true
|
50
|
+
end
|
51
|
+
|
52
|
+
Then /^it should have (no )?pending changes$/ do |empty|
|
53
|
+
@record.pending_changes?.should_not == !!empty
|
54
|
+
end
|
55
|
+
|
56
|
+
Then /^it should raise (.+?)$/ do |exception|
|
57
|
+
@last_error.class.should == eval(exception)
|
58
|
+
end
|
59
|
+
|
60
|
+
Then /^the (approval|record) should (not )?have (the changes|changed)$/ do |type, changed, tense|
|
61
|
+
changed = !!changed
|
62
|
+
changes = type == 'record' ? @record.attributes : @approval.object
|
63
|
+
|
64
|
+
@update.each_pair do |attr, value|
|
65
|
+
value = File.read(support_file_path(value)) if value =~ /^file:/
|
66
|
+
if changed
|
67
|
+
changes[attr].should_not == value
|
68
|
+
else
|
69
|
+
changes[attr].should == value
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
Then /^the (approval|record) should (not )?have changed to:$/ do |type, changed, table|
|
75
|
+
changed = !!changed
|
76
|
+
changes = type == 'record' ? @record.attributes : @approval.object
|
77
|
+
|
78
|
+
table.rows_hash.each_pair do |attr, value|
|
79
|
+
value = File.read(support_file_path(value)) if value =~ /^file:/
|
80
|
+
if changed
|
81
|
+
changes[attr].should_not == value
|
82
|
+
else
|
83
|
+
changes[attr].should == value
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
ENV['RAILS_ENV'] = 'test'
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'active_record'
|
5
|
+
|
6
|
+
require File.expand_path('../../lib/acts-as-approvable', File.dirname(__FILE__))
|
7
|
+
|
8
|
+
require File.expand_path('../../spec/support/database', File.dirname(__FILE__))
|
9
|
+
require File.expand_path('../../spec/support/models', File.dirname(__FILE__))
|
10
|
+
|
11
|
+
Before do
|
12
|
+
LOGGER = Support::Database.setup_log unless defined?(LOGGER)
|
13
|
+
Support::Database.load_schema
|
14
|
+
end
|