Skip to content

Commit

Permalink
code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaiprivalov committed Oct 22, 2019
1 parent 939d17f commit baf2006
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
8 changes: 4 additions & 4 deletions app/controllers/api/action_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ def destroy

def move
if @action_item.move!(@board)
head :no_content
head :ok
else
render json: { error: @action_item.errors.full_messages.join(',') }, status: :bad_request
end
end

def close
if @action_item.close!
head :no_content
head :ok
else
render json: { error: @action_item.errors.full_messages.join(',') }, status: :bad_request
end
end

def complete
if @action_item.complete!
head :no_content
head :ok
else
render json: { error: @action_item.errors.full_messages.join(',') }, status: :bad_request
end
end

def reopen
if @action_item.reopen!
head :no_content
head :ok
else
render json: { error: @action_item.errors.full_messages.join(',') }, status: :bad_request
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ActionItemFooter extends React.Component {
'X-CSRF-Token': document.querySelector("meta[name='csrf-token']").getAttribute('content')
}
}).then((result) => {
if (result.status == 204) {
if (result.status == 200) {
window.location.reload();
}
else { throw result }
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from "react"

import "./TransitionButton.css"

class TransitionButton extends React.Component {
constructor(props) {
super(props)
Expand All @@ -17,8 +15,7 @@ class TransitionButton extends React.Component {
'X-CSRF-Token': document.querySelector("meta[name='csrf-token']").getAttribute('content')
}
}).then((result) => {
if (result.status == 204) {
console.log(`doing ${this.props.action}!!!`)
if (result.status == 200) {
window.location.reload();
}
else { throw result }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

class AddTimesMovedToActionItems < ActiveRecord::Migration[6.0]
def change
add_column :action_items, :times_moved, :integer, default: 0
add_column :action_items, :times_moved, :integer, default: 0, null: false
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
t.string "status", default: "pending", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "times_moved", default: 0
t.integer "times_moved", default: 0, null: false
t.index ["board_id"], name: "index_action_items_on_board_id"
end

Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/api/action_items_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
allow(action_item).to receive(:move!).with(board).and_return(true)
end

it_behaves_like :controllers_api_successful_action, :no_content
it_behaves_like :controllers_api_successful_action
end
end

Expand Down Expand Up @@ -144,7 +144,7 @@
allow(action_item).to receive(:close!).and_return(true)
end

it_behaves_like :controllers_api_successful_action, :no_content
it_behaves_like :controllers_api_successful_action
end
end

Expand Down Expand Up @@ -177,7 +177,7 @@
allow(action_item).to receive(:complete!).and_return(true)
end

it_behaves_like :controllers_api_successful_action, :no_content
it_behaves_like :controllers_api_successful_action
end
end

Expand Down Expand Up @@ -210,7 +210,7 @@
allow(action_item).to receive(:reopen!).and_return(true)
end

it_behaves_like :controllers_api_successful_action, :no_content
it_behaves_like :controllers_api_successful_action
end
end
end

0 comments on commit baf2006

Please sign in to comment.