Skip to content

Commit

Permalink
edit issue title
Browse files Browse the repository at this point in the history
  • Loading branch information
Lupeipei committed Nov 19, 2018
1 parent 1c87fb5 commit a591832
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 0 additions & 1 deletion app/controllers/projects/issues_controller.rb
Expand Up @@ -43,7 +43,6 @@ def create
@task = Task.find(params[:task_id]) if params[:task_id]
@issue.creator ||= current_member
@issue.tasks = [ @task ] if @task
@issue.subscribed_users = [ @user ]
@issue.save
respond_with @issue, location: ok_url_or_default(action: :index)
end
Expand Down
15 changes: 15 additions & 0 deletions app/views/projects/issues/edit.html.erb
@@ -0,0 +1,15 @@
<div class="page-header">
<h2><%= page_i18n :edit, model_name: h(@issue) %></h2>
</div>

<div class="container">
<%= bootstrap_vertical_form_for [ @project, @task, @issue ], permit_for: issue_params_names do |f| %>
<%= f.input :title %>

<hr>

<%= ok_url_tag %>
<%= f.submit class: "btn btn-primary" %>
<%= cancel_link [@project, @task, @issue], class: "btn btn-secondary" %>
<% end %>
</div>
3 changes: 3 additions & 0 deletions app/views/projects/issues/show.html.erb
@@ -1,5 +1,8 @@
<div class="page-header">
<h2><%= @issue.title %></h2>
<div class="ml-auto actions">
<%= edit_link apply_ok_url([:edit, @project, @issue]) if can? :edit, @issue %>
</div>
</div>

<div class="container-fluid">
Expand Down
9 changes: 8 additions & 1 deletion spec/controllers/projects/issues_controller_spec.rb
Expand Up @@ -85,6 +85,13 @@
end
end

describe "GET edit" do
let(:attribute) { {title: "update my issue" } }
action { get :edit, params: { project_id: project.id, id: issue.id, issue: attribute } }

it { is_expected.to respond_with :success }
end

describe "PUT update" do
context "update with valid attributes" do
let(:attributes) { { title: "issue update", content: "hello" } }
Expand All @@ -94,7 +101,7 @@
end

context "update with invalid attributes" do
let(:attributes) { { title: "", content: "hello" } }
let(:attributes) { { title: "" } }
action(skip: true) { put :update, params: { id: issue.id, issue: attributes, project_id: project.id } }
it { expect{ do_action }.to raise_error }
end
Expand Down

0 comments on commit a591832

Please sign in to comment.