Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

Commit

Permalink
Add optimistic locking to user stories
Browse files Browse the repository at this point in the history
  • Loading branch information
levent committed Aug 20, 2015
1 parent 9b30202 commit da9cbfc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
13 changes: 12 additions & 1 deletion app/controllers/user_stories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def update
render 'edit' and return false
end
redirect_back_or(project_backlog_index_path(@project))
rescue ActiveRecord::StaleObjectError
flash.now[:error] = "Another person has just updated that record"
render 'edit'
end

def plan
Expand Down Expand Up @@ -115,7 +118,15 @@ def user_story_must_exist
end

def user_story_params
params[:user_story].permit(:definition, :story_points, :stakeholder, :cannot_be_estimated, :description, { acceptance_criteria_attributes: [:id, :detail, :_destroy]}, {tasks_attributes: [:id, :definition, :description, :_destroy]})
params[:user_story].permit(
:lock_version,
:definition,
:story_points,
:stakeholder,
:cannot_be_estimated,
:description,
{ acceptance_criteria_attributes: [:id, :detail, :_destroy]},
{tasks_attributes: [:id, :definition, :description, :_destroy]})
end

def save_or_close_path(commit_param)
Expand Down
1 change: 1 addition & 0 deletions app/views/user_stories/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div class="row">

<div class="large-15 small-24 medium-24 columns">
<%= f.input :lock_version, as: 'hidden' %>
<%= f.input :definition, input_html: {rows: 5, placeholder: 'As a user I want blink tags around key navigation items so I can find them quicker...'} %>
<div class="row">
<div class="large-10 small-10 medium-10 columns">
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20150820113718_add_lock_version_to_user_stories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddLockVersionToUserStories < ActiveRecord::Migration
def change
add_column :user_stories, :lock_version, :integer, default: 0
end
end
10 changes: 5 additions & 5 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150217161258) do
ActiveRecord::Schema.define(version: 20150820113718) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -90,13 +90,12 @@
add_index "people", ["unsubscribe_token"], name: "index_people_on_unsubscribe_token", using: :btree

create_table "projects", force: :cascade do |t|
t.string "name", null: false
t.string "name", null: false
t.integer "iteration_length"
t.integer "velocity"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "deleted_at"
t.boolean "use_estimates", default: true
end

add_index "projects", ["name"], name: "index_projects_on_name", unique: true, using: :btree
Expand Down Expand Up @@ -184,6 +183,7 @@
t.string "stakeholder", default: ""
t.boolean "delta", default: false
t.integer "project_id"
t.integer "lock_version", default: 0
end

add_index "user_stories", ["project_id", "sprint_id"], name: "index_user_stories_on_project_id_and_sprint_id", using: :btree
Expand Down

0 comments on commit da9cbfc

Please sign in to comment.