coupler 0.0.4-java → 0.0.6-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/Gemfile +7 -8
  2. data/Gemfile.lock +43 -24
  3. data/VERSION +1 -1
  4. data/coupler.gemspec +27 -31
  5. data/features/wizard.feature +2 -1
  6. data/lib/coupler.rb +2 -2
  7. data/lib/coupler/base.rb +4 -0
  8. data/lib/coupler/extensions/connections.rb +2 -12
  9. data/lib/coupler/extensions/jobs.rb +4 -2
  10. data/lib/coupler/extensions/projects.rb +1 -1
  11. data/lib/coupler/helpers.rb +9 -1
  12. data/lib/coupler/models.rb +8 -0
  13. data/lib/coupler/models/comparison.rb +5 -4
  14. data/lib/coupler/models/connection.rb +10 -1
  15. data/lib/coupler/models/import.rb +3 -7
  16. data/lib/coupler/models/transformer.rb +1 -1
  17. data/lib/coupler/runner.rb +1 -1
  18. data/lib/coupler/scheduler.rb +1 -1
  19. data/tasks/test.rake +8 -0
  20. data/test/functional/test_base.rb +17 -0
  21. data/test/functional/test_connections.rb +81 -0
  22. data/test/functional/test_imports.rb +76 -0
  23. data/test/{integration/extensions → functional}/test_jobs.rb +21 -12
  24. data/test/functional/test_matchers.rb +108 -0
  25. data/test/functional/test_projects.rb +67 -0
  26. data/test/functional/test_resources.rb +126 -0
  27. data/test/{integration/extensions → functional}/test_results.rb +20 -29
  28. data/test/functional/test_scenarios.rb +92 -0
  29. data/test/functional/test_transformations.rb +106 -0
  30. data/test/functional/test_transformers.rb +68 -0
  31. data/test/helper.rb +30 -20
  32. data/test/integration/test_transformation.rb +6 -1
  33. data/test/unit/models/test_common_model.rb +2 -2
  34. data/test/unit/models/test_comparison.rb +8 -8
  35. data/test/unit/models/test_connection.rb +2 -2
  36. data/test/unit/models/test_field.rb +2 -2
  37. data/test/unit/models/test_import.rb +9 -4
  38. data/test/unit/models/test_job.rb +2 -2
  39. data/test/unit/models/test_matcher.rb +2 -2
  40. data/test/unit/models/test_project.rb +2 -2
  41. data/test/unit/models/test_resource.rb +2 -2
  42. data/test/unit/models/test_result.rb +2 -2
  43. data/test/unit/models/test_scenario.rb +2 -2
  44. data/test/unit/models/test_transformation.rb +2 -2
  45. data/test/unit/models/test_transformer.rb +12 -2
  46. data/test/unit/test_base.rb +1 -14
  47. data/test/unit/test_data_uploader.rb +1 -1
  48. data/test/unit/test_database.rb +1 -1
  49. data/test/unit/test_helpers.rb +2 -2
  50. data/test/unit/test_import_buffer.rb +40 -38
  51. data/test/unit/test_logger.rb +1 -1
  52. data/test/unit/test_models.rb +1 -1
  53. data/test/unit/test_runner.rb +1 -1
  54. data/test/unit/test_scheduler.rb +1 -1
  55. data/webroot/public/css/style.css +7 -5
  56. data/webroot/public/js/jquery.dataTables.min.js +130 -574
  57. data/webroot/views/connections/new.erb +41 -3
  58. data/webroot/views/imports/new.erb +2 -0
  59. data/webroot/views/jobs/list.erb +25 -21
  60. data/webroot/views/projects/index.erb +23 -15
  61. data/webroot/views/resources/list.erb +1 -2
  62. data/webroot/views/resources/new.erb +2 -2
  63. data/webroot/views/resources/show.erb +5 -2
  64. data/webroot/views/scenarios/new.erb +1 -1
  65. data/webroot/views/transformations/new.erb +1 -1
  66. metadata +30 -44
  67. data/lib/coupler/config.rb +0 -128
  68. data/test/coupler/models/test_import.rb +0 -221
  69. data/test/factories.rb +0 -91
  70. data/test/integration/extensions/test_connections.rb +0 -80
  71. data/test/integration/extensions/test_imports.rb +0 -94
  72. data/test/integration/extensions/test_matchers.rb +0 -134
  73. data/test/integration/extensions/test_projects.rb +0 -82
  74. data/test/integration/extensions/test_resources.rb +0 -150
  75. data/test/integration/extensions/test_scenarios.rb +0 -88
  76. data/test/integration/extensions/test_transformations.rb +0 -113
  77. data/test/integration/extensions/test_transformers.rb +0 -80
  78. data/vendor/h2-1.3.154.jar +0 -0
@@ -0,0 +1,126 @@
1
+ require 'helper'
2
+
3
+ module CouplerFunctionalTests
4
+ class TestResources < Coupler::Test::FunctionalTest
5
+ def self.startup
6
+ super
7
+ conn = new_connection('h2', :name => 'foo')
8
+ conn.database do |db|
9
+ db.create_table!(:foo) do
10
+ primary_key :id
11
+ String :foo
12
+ String :bar
13
+ end
14
+ db[:foo].insert({:foo => 'foo', :bar => 'bar'})
15
+ db[:foo].insert({:foo => 'bar', :bar => 'foo'})
16
+
17
+ db.create_table!(:bar) do
18
+ primary_key :id
19
+ String :baz
20
+ String :quux
21
+ end
22
+ end
23
+ end
24
+
25
+ def setup
26
+ super
27
+ stamp = Time.now - 50
28
+ @project = Project.create(:name => 'foo', :created_at => stamp)
29
+ @connection = new_connection('h2', :name => 'h2 connection', :created_at => stamp).save!
30
+ end
31
+
32
+ test "index" do
33
+ resource = Resource.create(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
34
+ visit "/projects/#{@project.id}/resources"
35
+ assert_equal 200, page.status_code
36
+ assert @project.reload.last_accessed_at
37
+ end
38
+
39
+ test "index with non existant project" do
40
+ visit "/projects/8675309/resources"
41
+ assert_equal "/projects", page.current_path
42
+ assert page.has_content?("The project you were looking for doesn't exist")
43
+ end
44
+
45
+ attribute(:javascript, true)
46
+ test "new database resource" do
47
+ visit "/projects/#{@project.id}/resources/new"
48
+ find('#resource-type-database').click
49
+ fill_in("Name", :with => 'bar')
50
+ fill_in("Table", :with => 'bar')
51
+ select(@connection.name, :from => "Connection")
52
+ click_button('Submit')
53
+ assert_match %r{/projects/#{@project.id}/resources/\d+/edit}, page.current_path
54
+ assert Resource[:name => 'bar', :project_id => @project.id]
55
+ end
56
+
57
+ attribute(:javascript, true)
58
+ test "creating resource with errors" do
59
+ visit "/projects/#{@project.id}/resources/new"
60
+ find('#resource-type-database').click
61
+ fill_in("Name", :with => '')
62
+ fill_in("Table", :with => 'bar')
63
+ select(@connection.name, :from => "Connection")
64
+ click_button('Submit')
65
+ assert_equal "/projects/#{@project.id}/resources", page.current_path
66
+ assert page.has_content?("Name is not present")
67
+ end
68
+
69
+ test "show resource" do
70
+ resource = Resource.create!(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
71
+ field = resource.fields_dataset[:name => 'foo']
72
+ transformer = Transformer.create!(:name => 'noop', :code => 'value', :allowed_types => %w{string}, :result_type => 'same')
73
+ transformation = Transformation.create!(:resource => resource, :transformer => transformer, :source_field => field)
74
+
75
+ visit "/projects/#{@project[:id]}/resources/#{resource.id}"
76
+ assert_equal 200, page.status_code
77
+
78
+ rows = all('table#fields tbody tr')
79
+ assert_equal 3, rows.length
80
+ rows.each_with_index do |row, i|
81
+ cells = row.all('td')
82
+ assert_equal %w{id foo bar}[i], cells[0].text
83
+ end
84
+ end
85
+
86
+ test "schedule transform job" do
87
+ resource = Resource.create!(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
88
+ field = resource.fields_dataset[:name => 'foo']
89
+ transformer = Transformer.create!(:name => 'noop', :code => 'value', :allowed_types => %w{string}, :result_type => 'same')
90
+ transformation = Transformation.create!(:resource => resource, :transformer => transformer, :source_field => field)
91
+
92
+ visit "/projects/#{@project[:id]}/resources/#{resource[:id]}"
93
+ click_button("Transform now")
94
+ assert_equal "/projects/#{@project[:id]}/resources/#{resource[:id]}", page.current_path
95
+ assert Job.filter(:name => 'transform', :resource_id => resource.id, :status => 'scheduled').count == 1
96
+ end
97
+
98
+ #def test_progress
99
+ #resource = Factory(:resource, :project => @project, :completed => 100, :total => 1000)
100
+ #get "/projects/#{@project.id}/resources/#{resource.id}/progress"
101
+ #assert last_response.ok?
102
+ #assert_equal "10", last_response.body
103
+ #end
104
+
105
+ attribute(:javascript, true)
106
+ test "edit" do
107
+ resource = Resource.create!(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
108
+ field = resource.fields_dataset[:name => 'foo']
109
+
110
+ visit "/projects/#{@project[:id]}/resources/#{resource.id}/edit"
111
+ find("#field_checkbox_#{field.id}").click
112
+ click_button('Submit')
113
+ assert_equal "/projects/#{@project[:id]}/resources/#{resource.id}", page.current_path
114
+ end
115
+
116
+ #def test_delete
117
+ #pend
118
+ #end
119
+
120
+ test "record" do
121
+ resource = Resource.create!(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
122
+ page.driver.get "/projects/#{@project.id}/resources/#{resource.id}/record/1"
123
+ assert_equal 200, page.status_code
124
+ end
125
+ end
126
+ end
@@ -1,7 +1,7 @@
1
1
  require 'helper'
2
2
 
3
- module TestExtensions
4
- class TestResults < Coupler::Test::IntegrationTest
3
+ module CouplerFunctionalTests
4
+ class TestResults < Coupler::Test::FunctionalTest
5
5
  def self.startup
6
6
  super
7
7
  conn = new_connection('h2', :name => 'foo')
@@ -37,53 +37,44 @@ module TestExtensions
37
37
  end
38
38
 
39
39
  test "index" do
40
- get "/projects/#{@project.id}/scenarios/#{@scenario.id}/results"
41
- assert last_response.ok?
40
+ visit "/projects/#{@project.id}/scenarios/#{@scenario.id}/results"
41
+ assert_equal 200, page.status_code
42
42
  end
43
43
 
44
44
  test "index with non existant project" do
45
- get "/projects/8675309/scenarios/#{@scenario.id}/results"
46
- assert last_response.redirect?
47
- assert_equal "http://example.org/projects", last_response['location']
48
- follow_redirect!
49
- assert_match /The project you were looking for doesn't exist/, last_response.body
45
+ visit "/projects/8675309/scenarios/#{@scenario.id}/results"
46
+ assert_equal "/projects", page.current_path
47
+ assert page.has_content?("The project you were looking for doesn't exist")
50
48
  end
51
49
 
52
50
  test "index with non existant scenario" do
53
- get "/projects/#{@project.id}/scenarios/8675309/results"
54
- assert last_response.redirect?
55
- assert_equal "http://example.org/projects/#{@project.id}/scenarios", last_response['location']
56
- follow_redirect!
57
- assert_match /The scenario you were looking for doesn't exist/, last_response.body
51
+ visit "/projects/#{@project.id}/scenarios/8675309/results"
52
+ assert_equal "/projects/#{@project.id}/scenarios", page.current_path
53
+ assert page.has_content?("The scenario you were looking for doesn't exist")
58
54
  end
59
55
 
60
56
  test "show" do
61
- get "/projects/#{@project.id}/scenarios/#{@scenario.id}/results/#{@result.id}"
62
- assert last_response.ok?
57
+ visit "/projects/#{@project.id}/scenarios/#{@scenario.id}/results/#{@result.id}"
58
+ assert_equal 200, page.status_code
63
59
  end
64
60
 
65
61
  test "details" do
66
62
  group_id = nil
67
63
  @result.groups_dataset { |ds| group_id = ds.get(:id) }
68
- get "/projects/#{@project.id}/scenarios/#{@scenario.id}/results/#{@result.id}/details/#{group_id}"
69
- assert last_response.ok?
64
+ visit "/projects/#{@project.id}/scenarios/#{@scenario.id}/results/#{@result.id}/details/#{group_id}"
65
+ assert_equal 200, page.status_code
70
66
  end
71
67
 
72
68
  test "show sends csv" do
73
- get "/projects/#{@project.id}/scenarios/#{@scenario.id}/results/#{@result.id}.csv"
74
- assert_equal %{attachment; filename="#{@scenario.slug}-run-#{@result.created_at.strftime('%Y%m%d-%H%M')}.csv"}, last_response['Content-Disposition']
75
-
76
- body = last_response.body
77
- regexp = /id,foo,bar,coupler_group_id/
78
- assert_match regexp, body
69
+ visit "/projects/#{@project.id}/scenarios/#{@scenario.id}/results/#{@result.id}.csv"
70
+ assert_equal %{attachment; filename="#{@scenario.slug}-run-#{@result.created_at.strftime('%Y%m%d-%H%M')}.csv"}, page.response_headers['Content-Disposition']
71
+ assert page.has_content?("id,foo,bar,coupler_group_id")
79
72
  end
80
73
 
81
74
  test "show with non existant result" do
82
- get "/projects/#{@project.id}/scenarios/#{@scenario.id}/results/8675309"
83
- assert last_response.redirect?
84
- assert_equal "http://example.org/projects/#{@project.id}/scenarios/#{@scenario.id}/results", last_response['location']
85
- follow_redirect!
86
- assert_match /The result you were looking for doesn't exist/, last_response.body
75
+ visit "/projects/#{@project.id}/scenarios/#{@scenario.id}/results/8675309"
76
+ assert_equal "/projects/#{@project.id}/scenarios/#{@scenario.id}/results", page.current_path
77
+ assert page.has_content?("The result you were looking for doesn't exist")
87
78
  end
88
79
  end
89
80
  end
@@ -0,0 +1,92 @@
1
+ require 'helper'
2
+
3
+ module CouplerFunctionalTests
4
+ class TestScenarios < Coupler::Test::FunctionalTest
5
+ def self.startup
6
+ super
7
+ conn = new_connection('h2', :name => 'foo')
8
+ conn.database do |db|
9
+ db.create_table!(:foo) do
10
+ primary_key :id
11
+ String :foo
12
+ String :bar
13
+ end
14
+ db[:foo].insert({:foo => 'foo', :bar => 'bar'})
15
+ db[:foo].insert({:foo => 'bar', :bar => 'foo'})
16
+ end
17
+ end
18
+
19
+ def setup
20
+ super
21
+ @project = Project.create(:name => 'foo')
22
+ @connection = new_connection('h2', :name => 'h2 connection').save!
23
+ @resource = Resource.create(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
24
+ end
25
+
26
+ test "index" do
27
+ scenario = Scenario.create(:name => 'foo', :resource_1 => @resource, :project => @project)
28
+ visit "/projects/#{@project.id}/scenarios"
29
+ assert_equal 200, page.status_code
30
+ end
31
+
32
+ test "index of non existant project" do
33
+ visit "/projects/8675309/scenarios"
34
+ assert_equal "/projects", page.current_path
35
+ assert page.has_content?("The project you were looking for doesn't exist")
36
+ end
37
+
38
+ test "show" do
39
+ scenario = Scenario.create(:name => 'foo', :resource_1 => @resource, :project => @project)
40
+ visit "/projects/#{@project.id}/scenarios/#{scenario.id}"
41
+ assert_equal 200, page.status_code
42
+ end
43
+
44
+ attribute(:javascript, true)
45
+ test "successfully creating scenario" do
46
+ visit "/projects/#{@project.id}/scenarios/new"
47
+ fill_in('Name', :with => 'foo')
48
+ fill_in('Description', :with => 'foo bar')
49
+ find("#resource-#{@resource.id}").click
50
+ click_button('Submit')
51
+ assert_match %r{/projects/#{@project.id}/scenarios/\d+}, page.current_path
52
+ scenario = Scenario[:name => 'foo', :project_id => @project.id]
53
+ assert scenario
54
+ assert_equal [@resource], scenario.resources
55
+ end
56
+
57
+ attribute(:javascript, true)
58
+ test "failing to create scenario" do
59
+ visit "/projects/#{@project.id}/scenarios/new"
60
+ fill_in('Name', :with => '')
61
+ fill_in('Description', :with => 'foo bar')
62
+ find("#resource-#{@resource.id}").click
63
+ click_button('Submit')
64
+ assert_equal "/projects/#{@project.id}/scenarios", page.current_path
65
+ assert page.has_content?("Name is not present")
66
+ end
67
+
68
+ test "run scenario" do
69
+ scenario = Scenario.create(:name => 'foo', :resource_1 => @resource, :project => @project)
70
+ foo = @resource.fields_dataset[:name => 'foo']
71
+ matcher = Matcher.create!({
72
+ :scenario => scenario,
73
+ :comparisons_attributes => [{
74
+ 'lhs_type' => 'field', 'raw_lhs_value' => foo.id, 'lhs_which' => 1,
75
+ 'rhs_type' => 'field', 'raw_rhs_value' => foo.id, 'rhs_which' => 2,
76
+ 'operator' => 'equals'
77
+ }]
78
+ })
79
+ visit "/projects/#{@project.id}/scenarios/#{scenario.id}"
80
+ click_button('Run now')
81
+ assert_equal "/projects/#{@project[:id]}/scenarios/#{scenario[:id]}", page.current_path
82
+ assert Job.filter(:name => 'run_scenario', :scenario_id => scenario.id, :status => 'scheduled').count == 1
83
+ end
84
+
85
+ #def test_progress
86
+ #scenario = Factory(:scenario, :project => @project, :completed => 100, :total => 1000)
87
+ #visit "/projects/#{@project.id}/scenarios/#{scenario.id}/progress"
88
+ #assert_equal 200, page.status_code
89
+ #assert_equal "10", last_response.body
90
+ #end
91
+ end
92
+ end
@@ -0,0 +1,106 @@
1
+ require 'helper'
2
+
3
+ module CouplerFunctionalTests
4
+ class TestTransformations < Coupler::Test::FunctionalTest
5
+ def self.startup
6
+ super
7
+ conn = new_connection('h2', :name => 'foo')
8
+ conn.database do |db|
9
+ db.create_table!(:foo) do
10
+ primary_key :id
11
+ String :foo
12
+ String :bar
13
+ end
14
+ db[:foo].insert({:foo => 'foo', :bar => 'bar'})
15
+ db[:foo].insert({:foo => 'bar', :bar => 'foo'})
16
+ end
17
+ end
18
+
19
+ def setup
20
+ super
21
+ @project = Project.create(:name => 'foo')
22
+ @connection = new_connection('h2', :name => 'h2 connection').save!
23
+ @resource = Resource.create(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
24
+ @transformer = Transformer.create(:name => 'noop', :code => 'value', :allowed_types => %w{string integer datetime}, :result_type => 'same')
25
+ end
26
+
27
+ attribute(:javascript, true)
28
+ test "new" do
29
+ pend "I hate Capybara sometimes"
30
+ visit "/projects/#{@project.id}/resources/#{@resource.id}/transformations/new"
31
+ find('#source-field-name input.ui-autocomplete-input').set('foo')
32
+ find('#transformer-name input.ui-autocomplete-input').set(@transformer.name)
33
+ choose("Same as source field")
34
+ click_button('Submit')
35
+ assert_equal "/projects/#{@project.id}/resources/#{@resource.id}", page.current_path
36
+ transformation = @resource.transformations_dataset.first
37
+ assert transformation
38
+ end
39
+
40
+ test "new with non existant project" do
41
+ visit "/projects/8675309/resources/#{@resource.id}/transformations/new"
42
+ assert_equal "/projects", page.current_path
43
+ assert page.has_content?("The project you were looking for doesn't exist")
44
+ end
45
+
46
+ test "new with non existant resource" do
47
+ visit "/projects/#{@project.id}/resources/8675309/transformations/new"
48
+ assert_equal "/projects/#{@project.id}/resources", page.current_path
49
+ assert page.has_content?("The resource you were looking for doesn't exist")
50
+ end
51
+
52
+ attribute(:javascript, true)
53
+ test "delete" do
54
+ field = @resource.fields_dataset[:name => 'foo']
55
+ transformation = Transformation.create!(:resource => @resource, :transformer => @transformer, :source_field => field)
56
+
57
+ visit "/projects/#{@project.id}/resources/#{@resource.id}/transformations"
58
+ find('span.ui-icon-trash').click
59
+ a = page.driver.browser.switch_to.alert
60
+ a.accept
61
+ assert_equal "/projects/#{@project.id}/resources/#{@resource.id}", page.current_path
62
+ assert_equal 0, Transformation.filter(:id => transformation.id).count
63
+ end
64
+
65
+ # NOTE: Capybara doesn't do so well with this
66
+ #test "delete with non existant transformation" do
67
+ #page.driver.delete "/projects/#{@project.id}/resources/#{@resource.id}/transformations/8675309"
68
+ #assert_equal "/projects/#{@project.id}/resources/#{@resource.id}/transformations", page.current_path
69
+ #assert page.has_content?("The transformation you were looking for doesn't exist")
70
+ #end
71
+
72
+ test "for" do
73
+ field = @resource.fields_dataset[:name => 'foo']
74
+ t12n = Transformation.create!(:resource => @resource, :source_field => field, :transformer => @transformer)
75
+
76
+ page.driver.get "/projects/#{@project.id}/resources/#{@resource.id}/transformations/for/foo"
77
+ assert page.has_content?("noop")
78
+ end
79
+
80
+ # NOTE: Capybara doesn't do so well with this
81
+ #test "for with non existant field" do
82
+ #page.driver.get "/projects/#{@project.id}/resources/#{@resource.id}/transformations/for/gobbledegook"
83
+ #assert_equal 200, page.status_code
84
+ #assert_equal '', page.html
85
+ #end
86
+
87
+ test "index" do
88
+ field = @resource.fields_dataset[:name => 'foo']
89
+ t12n = Transformation.create!(:resource => @resource, :source_field => field, :transformer => @transformer)
90
+
91
+ visit "/projects/#{@project.id}/resources/#{@resource.id}/transformations"
92
+ assert_equal 200, page.status_code
93
+ end
94
+
95
+ test "preview" do
96
+ field = @resource.fields_dataset[:name => 'foo']
97
+ params = {
98
+ :transformer_id => @transformer.id.to_s,
99
+ :source_field_id => field.id.to_s,
100
+ :result_field_id => field.id.to_s
101
+ }
102
+ page.driver.post "/projects/#{@project.id}/resources/#{@resource.id}/transformations/preview", :transformation => params
103
+ assert_equal 200, page.status_code
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,68 @@
1
+ require 'helper'
2
+
3
+ module CouplerFunctionalTests
4
+ class TestTransformers < Coupler::Test::FunctionalTest
5
+ test "index" do
6
+ visit '/transformers'
7
+ assert_equal 200, page.status_code
8
+ end
9
+
10
+ test "new" do
11
+ visit '/transformers/new'
12
+ fill_in('Name', :with => 'noop')
13
+ select('String', :from => 'Allowed Field Types')
14
+ select('String', :from => 'Result Type')
15
+ fill_in('Code', :with => 'value')
16
+ click_button('Submit')
17
+ assert_equal "/transformers", page.current_path
18
+ assert Transformer[:name => 'noop']
19
+ end
20
+
21
+ test "failed create" do
22
+ visit '/transformers/new'
23
+ fill_in('Name', :with => '')
24
+ select('String', :from => 'Allowed Field Types')
25
+ select('String', :from => 'Result Type')
26
+ fill_in('Code', :with => 'value')
27
+ click_button('Submit')
28
+ assert page.has_content?("Name is not present")
29
+ end
30
+
31
+ test "edit" do
32
+ xformer = Transformer.create(:name => 'noop', :code => 'value', :allowed_types => %w{string}, :result_type => 'string')
33
+ visit "/transformers/#{xformer.id}/edit"
34
+ fill_in('Name', :with => 'foo')
35
+ click_button('Submit')
36
+ assert_equal "/transformers", page.current_path
37
+ xformer.reload
38
+ assert_equal 'foo', xformer.name
39
+ end
40
+
41
+ test "failed update" do
42
+ xformer = Transformer.create(:name => 'noop', :code => 'value', :allowed_types => %w{string}, :result_type => 'string')
43
+ visit "/transformers/#{xformer.id}/edit"
44
+ fill_in('Code', :with => 'foo(')
45
+ click_button('Submit')
46
+ assert page.has_content?("Code has errors")
47
+ end
48
+
49
+ #test "preview" do
50
+ #post "/transformers/preview", :transformer => { 'code' => 'value.downcase', 'allowed_types' => %w{string}, 'result_type' => 'string' }
51
+ #assert_equal 200, page.status_code
52
+ #end
53
+
54
+ #test "delete" do
55
+ #xformer = Transformer.create(:name => 'noop', :code => 'value', :allowed_types => %w{string}, :result_type => 'string')
56
+ #delete "/transformers/#{xformer.id}"
57
+ #assert_equal 0, Transformer.filter(:id => xformer.id).count
58
+ #assert last_response.redirect?, last_response.inspect
59
+ #assert_equal "http://example.org/transformers", page.current_path
60
+ #end
61
+
62
+ #test "show" do
63
+ #xformer = Transformer.create(:name => 'noop', :code => 'value', :allowed_types => %w{string}, :result_type => 'string')
64
+ #visit "/transformers/#{xformer.id}"
65
+ #assert_equal 200, page.status_code
66
+ #end
67
+ end
68
+ end