on_the_spot 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -7,4 +7,6 @@ gem "json_pure"
7
7
  group :test do
8
8
  gem "rspec", ">= 2.0.0.rc"
9
9
  gem "actionpack", ">=3.0.0"
10
+ #gem "rcov"
11
+ gem "simplecov", :require => false
10
12
  end
@@ -47,6 +47,9 @@ GEM
47
47
  rspec-expectations (= 2.0.0.rc)
48
48
  rubyforge (2.0.4)
49
49
  json_pure (>= 1.1.7)
50
+ simplecov (0.3.6)
51
+ simplecov-html (>= 0.3.7)
52
+ simplecov-html (0.3.8)
50
53
  tzinfo (0.3.23)
51
54
 
52
55
  PLATFORMS
@@ -55,5 +58,7 @@ PLATFORMS
55
58
  DEPENDENCIES
56
59
  actionpack (>= 3.0.0)
57
60
  jeweler
61
+ json_pure
58
62
  rake
59
63
  rspec (>= 2.0.0.rc)
64
+ simplecov
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -21,7 +21,12 @@ $(document).ready(function() {
21
21
  var options = {
22
22
  tooltip: tooltip_text,
23
23
  cancel: cancel_text,
24
- submit: ok_text
24
+ submit: ok_text,
25
+ onerror: function (settings, original, xhr) {
26
+ original.reset();
27
+ //just show the error-msg for now
28
+ alert(xhr.responseText);
29
+ }
25
30
  };
26
31
  if (edit_type != null) {
27
32
  options.type = edit_type;
@@ -37,7 +42,7 @@ $(document).ready(function() {
37
42
  }
38
43
  else if (edit_type == 'textarea') {
39
44
  options.rows = rows;
40
- options.columns = columns;
45
+ options.cols = columns;
41
46
  }
42
47
 
43
48
  el.editable(data_url, options)
@@ -13,12 +13,15 @@ module OnTheSpot
13
13
  klass, field, id = params[:id].split('__')
14
14
  select_data = params[:select_array]
15
15
  object = klass.camelize.constantize.find(id)
16
- object.update_attribute(field, params[:value])
17
- if select_data.nil?
18
- render :text => CGI::escapeHTML(object.send(field).to_s)
16
+ if object.update_attributes(field => params[:value])
17
+ if select_data.nil?
18
+ render :text => CGI::escapeHTML(object.send(field).to_s)
19
+ else
20
+ parsed_data = JSON.parse(select_data.gsub("'", '"'))
21
+ render :text => parsed_data[object.send(field).to_s]
22
+ end
19
23
  else
20
- parsed_data = JSON.parse(select_data.gsub("'", '"'))
21
- render :text => parsed_data[object.send(field).to_s]
24
+ render :text => object.errors.full_messages.join("\n"), :status => 422
22
25
  end
23
26
  end
24
27
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{on_the_spot}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nathan Van der Auwera"]
12
- s.date = %q{2010-10-07}
12
+ s.date = %q{2010-11-05}
13
13
  s.description = %q{Unobtrusive in place editing, using jEditable; only works in Rails 3}
14
14
  s.email = %q{nathan@dixis.com}
15
15
  s.extra_rdoc_files = [
@@ -37,7 +37,7 @@ describe "OnTheSpot" do
37
37
  end
38
38
  end
39
39
 
40
- context "creating a simple edit-field" do
40
+ context "the helpers" do
41
41
  before(:each) do
42
42
  @dummy = mock()
43
43
  @dummy.stub!(:content).and_return('test')
@@ -46,11 +46,22 @@ describe "OnTheSpot" do
46
46
  @tester.should_receive(:t).with('on_the_spot.cancel').and_return("cancel")
47
47
  @tester.should_receive(:t).with('on_the_spot.tooltip').and_return("tooltip")
48
48
  @tester.should_receive(:url_for).and_return('/bla')
49
- @result = @tester.on_the_spot_edit @dummy, :content
50
49
  end
51
- it "should make the correct html" do
50
+
51
+ it "should make the correct html for an edit-field" do
52
+ @result = @tester.on_the_spot_edit @dummy, :content
52
53
  @result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-ok=\"ok\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">test</span>"
53
54
  end
55
+
56
+ it "should make the correct html for a text-area" do
57
+ @result = @tester.on_the_spot_edit @dummy, :content, :type => :textarea
58
+ @result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-columns=\"40\" data-edittype=\"textarea\" data-ok=\"ok\" data-rows=\"5\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">test</span>"
59
+ end
60
+
61
+ it "should make the correct html for a select-box" do
62
+ @result = @tester.on_the_spot_edit @dummy, :content, :type => :select, :data => [['test', 'This a test'], ['prod', 'Pure Production'], ['QA', 'Quality Assurance']]
63
+ @result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-edittype=\"select\" data-ok=\"ok\" data-select=\"{ 'test':'This a test', 'prod':'Pure Production', 'QA':'Quality Assurance', 'selected':'test'}\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">This a test</span>"
64
+ end
54
65
  end
55
66
  end
56
67
  end
@@ -3,24 +3,10 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'rspec/core'
4
4
  #require 'autotest/rspec2'
5
5
 
6
-
6
+ require 'simplecov'
7
+ SimpleCov.start 'rails'
7
8
 
8
9
  RSpec.configure do |c|
9
10
  c.color_enabled = true
10
- # c.filter_run :focused => true
11
- # c.run_all_when_everything_filtered = true
12
- # c.filter_run_excluding :ruby => lambda {|version|
13
- # case version.to_s
14
- # when "!jruby"
15
- # RUBY_ENGINE != "jruby"
16
- # when /^> (.*)/
17
- # !(RUBY_VERSION.to_s > $1)
18
- # else
19
- # !(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
20
- # end
21
- # }
22
- # c.around do |example|
23
- # sandboxed { example.run }
24
- # end
25
11
  end
26
12
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nathan Van der Auwera
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-07 00:00:00 +02:00
17
+ date: 2010-11-05 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency