Domains#index is now the root page
This commit is contained in:
parent
d882c1a521
commit
b1009ec4de
@ -13,3 +13,27 @@
|
||||
*= require_tree .
|
||||
*= require_self
|
||||
*/
|
||||
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
*, *:before, *:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body, h1, h2, h3, h4, h5, h6, p, ol, ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
class CredentialsController < ApplicationController
|
||||
before_action :set_credential, only: %i[ show edit update destroy ]
|
||||
before_action :set_domain, only: %i[ new ]
|
||||
before_action :set_domain, only: %i[ new create edit update destroy ]
|
||||
|
||||
# GET /credentials or /credentials.json
|
||||
def index
|
||||
@ -23,10 +23,11 @@ class CredentialsController < ApplicationController
|
||||
# POST /credentials or /credentials.json
|
||||
def create
|
||||
@credential = Credential.new(credential_params)
|
||||
@credential.domain_id = @domain.id
|
||||
|
||||
respond_to do |format|
|
||||
if @credential.save
|
||||
format.html { redirect_to credential_url(@credential), notice: "Credential was successfully created." }
|
||||
format.html { redirect_to domain_path(@domain), notice: "Credential was successfully created." }
|
||||
format.json { render :show, status: :created, location: @credential }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
@ -39,7 +40,7 @@ class CredentialsController < ApplicationController
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @credential.update(credential_params)
|
||||
format.html { redirect_to credential_url(@credential), notice: "Credential was successfully updated." }
|
||||
format.html { redirect_to domain_path(@domain), notice: "Credential was successfully updated." }
|
||||
format.json { render :show, status: :ok, location: @credential }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
@ -53,7 +54,7 @@ class CredentialsController < ApplicationController
|
||||
@credential.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to credentials_url, notice: "Credential was successfully destroyed." }
|
||||
format.html { redirect_to domain_path(@domain), notice: "Credential was successfully destroyed." }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<%= form.label :email, style: "display: block" %>
|
||||
<%= form.label :email, style: "display: inline" %> @<%=@domain.domain%>
|
||||
<%= form.text_field :email %>
|
||||
</div>
|
||||
|
||||
|
||||
@ -5,6 +5,6 @@
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<%= link_to "Show this credential", @credential %> |
|
||||
<%= link_to "Back to credentials", credentials_path %>
|
||||
<%#= link_to "Show this credential", @credential %> |
|
||||
<%#= link_to "Back to credentials", credentials_path %>
|
||||
</div>
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
<p style="color: green"><%= notice %></p>
|
||||
|
||||
<h1>Domains</h1>
|
||||
|
||||
<div id="domains">
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
<p style="color: green"><%= notice %></p>
|
||||
<h1><%= @domain.domain %></h1>
|
||||
|
||||
<div>
|
||||
@ -9,7 +8,8 @@
|
||||
<ul>
|
||||
<li><%= link_to "Add #{@domain.domain} email address", new_domain_credential_path(@domain) %>
|
||||
<% @domain.credentials.each do |credential| %>
|
||||
<li><%= credential.email %></li>
|
||||
<li><%= credential.email %> <%= link_to "Edit", edit_domain_credential_path(@domain,credential) %> |
|
||||
<%= button_to "Destroy this credential", [@domain, credential], method: :delete %> </li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
|
||||
@ -9,5 +9,5 @@ Rails.application.routes.draw do
|
||||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
||||
|
||||
# Defines the root path route ("/")
|
||||
root "home#index"
|
||||
root "domains#index"
|
||||
end
|
||||
|
||||
@ -39,4 +39,14 @@ class VirtualTest < ActiveSupport::TestCase
|
||||
assert !@v.save
|
||||
end
|
||||
|
||||
test "domain id must be present" do
|
||||
@v = Virtual.new
|
||||
@v.email = "abuse@example.net"
|
||||
@v.destination = "valid@email.com"
|
||||
@v.domain_id = domains(:one).id + 1234
|
||||
assert !@v.save
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user