Skip to content

Commit

Permalink
Merge pull request #81 from ll100-cn/edit_issue_title
Browse files Browse the repository at this point in the history
edit issue title
  • Loading branch information
sunteya committed Nov 19, 2018
2 parents 1c87fb5 + ea88436 commit 58634bd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 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
13 changes: 10 additions & 3 deletions spec/controllers/projects/issues_controller_spec.rb
Expand Up @@ -85,6 +85,12 @@
end
end

describe "GET edit" do
action { get :edit, params: { project_id: project.id, id: issue.id } }

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,9 +100,10 @@
end

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

it { expect(issue.title).not_to be_empty }
end

context "update with state to generate activities" do
Expand Down

0 comments on commit 58634bd

Please sign in to comment.