diff --git a/app/views/integrations/rest_api.html.erb b/app/views/integrations/rest_api.html.erb index 0012d7e6..f401328f 100644 --- a/app/views/integrations/rest_api.html.erb +++ b/app/views/integrations/rest_api.html.erb @@ -20,7 +20,7 @@
- $ curl -u username:p4ssw0rd \
+ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
<%= home_url %>contexts.xml
>> <?xml version="1.0" encoding="UTF-8"?>
<contexts>...</contexts>
@@ -31,7 +31,7 @@
- $ curl -u username:p4ssw0rd \
+ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
<%= home_url %>contexts/51.xml
>> <?xml version="1.0" encoding="UTF-8"?>
<context>...</context>
@@ -42,7 +42,7 @@
- $ curl -u username:p4ssw0rd \
+ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
<%= home_url %>contexts/51/todos.xml
>> <?xml version="1.0" encoding="UTF-8"?>
<todos type="array">...</todos>
@@ -72,7 +72,7 @@
-$ curl -u username:p4ssw0rd \
+$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
-d "project[name]=Build a treehouse for the kids" \
<%= home_url %>projects.xml -i
>> HTTP/1.1 201 Created
@@ -85,7 +85,7 @@ Location: <%= home_url %>projects/65.xml
-$ curl -u username:p4ssw0rd \
+$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
-d "todo[description]=Model treehouse in SketchUp&todo[context_id]=2&todo[project_id]=65" \
<%= home_url %>todos.xml -i
>> HTTP/1.1 201 Created
@@ -98,7 +98,7 @@ Location: <%= home_url %>todos/452.xml
- $ curl -u username:p4ssw0rd -X PUT \
+ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" -X PUT \
-d "todo[notes]=use maple texture" \
<%= home_url %>todos/452.xml -i
>> HTTP/1.1 200 OK
@@ -119,7 +119,7 @@ Location: <%= home_url %>todos/452.xml
- $ curl -u username:p4ssw0rd -X PUT \
+ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" -X PUT \
<%= home_url %>todos/452/toggle_check.xml -i
>> HTTP/1.1 200 OK
...
@@ -140,7 +140,7 @@ Location: <%= home_url %>todos/452.xml
- $ curl -u username:p4ssw0rd -X DELETE \
+ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" -X DELETE \
<%= home_url %>todos/452.xml -i
>> HTTP/1.1 200 OK
...
@@ -159,7 +159,7 @@ Location: <%= home_url %>todos/452.xml
-$ curl -u username:p4ssw0rd \
+$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
<%= home_url %>contexts/2/todos.xml
>> <?xml version="1.0" encoding="UTF-8"?>
<nil-classes type="array"/>
@@ -215,4 +215,4 @@ irb(main):003:0>
... indicates that unimportant bits of response data have been removed to eliminate noise from the documentation
-All examples make use of cURL .
\ No newline at end of file
+All examples make use of cURL .
diff --git a/db/schema.rb b/db/schema.rb
index 51db5c38..abd744ae 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -9,43 +9,43 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20080617044632) do
+ActiveRecord::Schema.define(:version => 38) do
create_table "contexts", :force => true do |t|
- t.string "name", :default => "", :null => false
- t.integer "position", :limit => 11
- t.boolean "hide", :default => false
- t.integer "user_id", :limit => 11, :default => 1
+ t.string "name", :null => false
+ t.integer "position"
+ t.boolean "hide", :default => false
+ t.integer "user_id", :default => 1
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "contexts", ["user_id"], :name => "index_contexts_on_user_id"
add_index "contexts", ["user_id", "name"], :name => "index_contexts_on_user_id_and_name"
+ add_index "contexts", ["user_id"], :name => "index_contexts_on_user_id"
create_table "notes", :force => true do |t|
- t.integer "user_id", :limit => 11, :null => false
- t.integer "project_id", :limit => 11, :null => false
+ t.integer "user_id", :null => false
+ t.integer "project_id", :null => false
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "notes", ["project_id"], :name => "index_notes_on_project_id"
add_index "notes", ["user_id"], :name => "index_notes_on_user_id"
+ add_index "notes", ["project_id"], :name => "index_notes_on_project_id"
create_table "open_id_associations", :force => true do |t|
t.binary "server_url"
t.string "handle"
t.binary "secret"
- t.integer "issued", :limit => 11
- t.integer "lifetime", :limit => 11
+ t.integer "issued"
+ t.integer "lifetime"
t.string "assoc_type"
end
create_table "open_id_nonces", :force => true do |t|
t.string "nonce"
- t.integer "created", :limit => 11
+ t.integer "created"
end
create_table "open_id_settings", :force => true do |t|
@@ -54,40 +54,40 @@ ActiveRecord::Schema.define(:version => 20080617044632) do
end
create_table "preferences", :force => true do |t|
- t.integer "user_id", :limit => 11, :null => false
+ t.integer "user_id", :null => false
t.string "date_format", :limit => 40, :default => "%d/%m/%Y", :null => false
- t.integer "week_starts", :limit => 11, :default => 0, :null => false
- t.integer "show_number_completed", :limit => 11, :default => 5, :null => false
- t.integer "staleness_starts", :limit => 11, :default => 7, :null => false
+ t.integer "week_starts", :default => 0, :null => false
+ t.integer "show_number_completed", :default => 5, :null => false
+ t.integer "staleness_starts", :default => 7, :null => false
t.boolean "show_completed_projects_in_sidebar", :default => true, :null => false
t.boolean "show_hidden_contexts_in_sidebar", :default => true, :null => false
- t.integer "due_style", :limit => 11, :default => 0, :null => false
+ t.integer "due_style", :default => 0, :null => false
t.string "admin_email", :default => "butshesagirl@rousette.org.uk", :null => false
- t.integer "refresh", :limit => 11, :default => 0, :null => false
+ t.integer "refresh", :default => 0, :null => false
t.boolean "verbose_action_descriptors", :default => false, :null => false
t.boolean "show_hidden_projects_in_sidebar", :default => true, :null => false
t.string "time_zone", :default => "London", :null => false
t.boolean "show_project_on_todo_done", :default => false, :null => false
t.string "title_date_format", :default => "%A, %d %B %Y", :null => false
- t.integer "mobile_todos_per_page", :limit => 11, :default => 6, :null => false
+ t.integer "mobile_todos_per_page", :default => 6, :null => false
end
add_index "preferences", ["user_id"], :name => "index_preferences_on_user_id"
create_table "projects", :force => true do |t|
- t.string "name", :default => "", :null => false
- t.integer "position", :limit => 11
- t.integer "user_id", :limit => 11, :default => 1
+ t.string "name", :null => false
+ t.integer "position"
+ t.integer "user_id", :default => 1
t.text "description"
t.string "state", :limit => 20, :default => "active", :null => false
t.datetime "created_at"
t.datetime "updated_at"
- t.integer "default_context_id", :limit => 11
+ t.integer "default_context_id"
t.datetime "completed_at"
end
- add_index "projects", ["user_id"], :name => "index_projects_on_user_id"
add_index "projects", ["user_id", "name"], :name => "index_projects_on_user_id_and_name"
+ add_index "projects", ["user_id"], :name => "index_projects_on_user_id"
create_table "sessions", :force => true do |t|
t.string "session_id"
@@ -98,10 +98,10 @@ ActiveRecord::Schema.define(:version => 20080617044632) do
add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
create_table "taggings", :force => true do |t|
- t.integer "taggable_id", :limit => 11
- t.integer "tag_id", :limit => 11
+ t.integer "taggable_id"
+ t.integer "tag_id"
t.string "taggable_type"
- t.integer "user_id", :limit => 11
+ t.integer "user_id"
end
add_index "taggings", ["tag_id", "taggable_id", "taggable_type"], :name => "index_taggings_on_tag_id_and_taggable_id_and_taggable_type"
@@ -115,27 +115,27 @@ ActiveRecord::Schema.define(:version => 20080617044632) do
add_index "tags", ["name"], :name => "index_tags_on_name"
create_table "todos", :force => true do |t|
- t.integer "context_id", :limit => 11, :null => false
- t.integer "project_id", :limit => 11
- t.string "description", :default => "", :null => false
+ t.integer "context_id", :null => false
+ t.integer "project_id"
+ t.string "description", :null => false
t.text "notes"
t.datetime "created_at"
t.date "due"
t.datetime "completed_at"
- t.integer "user_id", :limit => 11, :default => 1
+ t.integer "user_id", :default => 1
t.date "show_from"
t.string "state", :limit => 20, :default => "immediate", :null => false
end
- add_index "todos", ["user_id", "state"], :name => "index_todos_on_user_id_and_state"
- add_index "todos", ["user_id", "project_id"], :name => "index_todos_on_user_id_and_project_id"
- add_index "todos", ["project_id"], :name => "index_todos_on_project_id"
- add_index "todos", ["context_id"], :name => "index_todos_on_context_id"
add_index "todos", ["user_id", "context_id"], :name => "index_todos_on_user_id_and_context_id"
+ add_index "todos", ["context_id"], :name => "index_todos_on_context_id"
+ add_index "todos", ["project_id"], :name => "index_todos_on_project_id"
+ add_index "todos", ["user_id", "project_id"], :name => "index_todos_on_user_id_and_project_id"
+ add_index "todos", ["user_id", "state"], :name => "index_todos_on_user_id_and_state"
create_table "users", :force => true do |t|
- t.string "login", :limit => 80, :default => "", :null => false
- t.string "crypted_password", :limit => 40
+ t.string "login", :limit => 80, :null => false
+ t.string "crypted_password", :limit => 40, :null => false
t.string "token"
t.boolean "is_admin", :default => false, :null => false
t.string "first_name"
diff --git a/spec/fixtures/contexts.yml b/spec/fixtures/contexts.yml
new file mode 100644
index 00000000..5bf02933
--- /dev/null
+++ b/spec/fixtures/contexts.yml
@@ -0,0 +1,7 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+# one:
+# column: value
+#
+# two:
+# column: value
diff --git a/spec/models/context_spec.rb b/spec/models/context_spec.rb
new file mode 100644
index 00000000..74ece6d0
--- /dev/null
+++ b/spec/models/context_spec.rb
@@ -0,0 +1,68 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+module ContextSpecHelper
+
+ def valid_context_attributes
+ {
+ :name => "FooBar",
+ :position => 1,
+ :hide => true,
+ :user_id => 1
+ }
+ end
+
+end
+
+ describe Context do
+ include ContextSpecHelper
+
+ before(:each) do
+ @context = Context.new
+ end
+
+ it "should be valid" do
+ @context.name = "FooBar"
+ @context.should be_valid
+ end
+
+ it "should have one error with a name of more than 255 characters" do
+ @context.name = "z" * 256
+ @context.should have(1).error_on(:name)
+ end
+
+ it "should have one error with name containing comma" do
+ @context.name = "Foo,Bar"
+ @context.should have(1).error_on(:name)
+ end
+
+ it "should have one record in Context model class" do
+ @context.name = "FooBar"
+ @context.save
+ Context.should have(1).record
+ end
+
+ it "should be hidden" do
+ @context.attributes = valid_context_attributes
+ @context.should be_hide # :hide should be true
+ end
+
+ it "should be produce correct summary text for hidden context" do
+ @context.attributes = valid_context_attributes
+ @context.summary(1).should eql("1. Context is Hidden.
")
+ end
+
+ it "should be active" do
+ @context.attributes = valid_context_attributes
+ @context.hide = false
+ @context.save
+ @context.should_not be_hide # :hide should be true
+ end
+
+ it "should produce correct summary text for active context" do
+ @context.attributes = valid_context_attributes
+ @context.hide = false
+ @context.save
+ @context.summary(1).should eql("1. Context is Active.
")
+ end
+
+ end