diff --git a/app/views/apps/_fields.html.haml b/app/views/apps/_fields.html.haml
index 46df9a3..ca9bbab 100644
--- a/app/views/apps/_fields.html.haml
+++ b/app/views/apps/_fields.html.haml
@@ -4,10 +4,11 @@
= f.label :name
= f.text_field :name
-%div
- %label Api Key
- %span= app.api_key
- = link_to t('.regenerate_api_key'), regenerate_api_key_app_path(app), :class => 'button', :method => 'post'
+- unless app.new_record?
+ %div
+ %label Api Key
+ %span= app.api_key
+ = link_to t('.regenerate_api_key'), regenerate_api_key_app_path(app), :class => 'button', :method => 'post'
%div
= f.label :repository_branch
= f.text_field :repository_branch, :placeholder => "master"
diff --git a/spec/acceptance/app_regenerate_api_key_spec.rb b/spec/acceptance/app_regenerate_api_key_spec.rb
index a5494e0..e6062c3 100644
--- a/spec/acceptance/app_regenerate_api_key_spec.rb
+++ b/spec/acceptance/app_regenerate_api_key_spec.rb
@@ -17,6 +17,9 @@ feature "Regeneration api_Key" do
}.to change {
app.reload.api_key
}
+ click_link I18n.t('shared.navigation.apps')
+ click_link I18n.t('apps.index.new_app')
+ expect(page).to_not have_button I18n.t('apps.fields.regenerate_api_key')
end
scenario "a user cannot access to edit page" do
--
libgit2 0.21.2