Domains#index is now the root page

This commit is contained in:
Jez Caudle 2023-06-21 17:23:20 +01:00
parent d882c1a521
commit b1009ec4de
8 changed files with 45 additions and 12 deletions

View File

@ -13,3 +13,27 @@
*= require_tree . *= require_tree .
*= require_self *= 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;
}

View File

@ -1,6 +1,6 @@
class CredentialsController < ApplicationController class CredentialsController < ApplicationController
before_action :set_credential, only: %i[ show edit update destroy ] 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 # GET /credentials or /credentials.json
def index def index
@ -23,10 +23,11 @@ class CredentialsController < ApplicationController
# POST /credentials or /credentials.json # POST /credentials or /credentials.json
def create def create
@credential = Credential.new(credential_params) @credential = Credential.new(credential_params)
@credential.domain_id = @domain.id
respond_to do |format| respond_to do |format|
if @credential.save 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 } format.json { render :show, status: :created, location: @credential }
else else
format.html { render :new, status: :unprocessable_entity } format.html { render :new, status: :unprocessable_entity }
@ -39,7 +40,7 @@ class CredentialsController < ApplicationController
def update def update
respond_to do |format| respond_to do |format|
if @credential.update(credential_params) 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 } format.json { render :show, status: :ok, location: @credential }
else else
format.html { render :edit, status: :unprocessable_entity } format.html { render :edit, status: :unprocessable_entity }
@ -53,7 +54,7 @@ class CredentialsController < ApplicationController
@credential.destroy @credential.destroy
respond_to do |format| 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 } format.json { head :no_content }
end end
end end

View File

@ -12,7 +12,7 @@
<% end %> <% end %>
<div> <div>
<%= form.label :email, style: "display: block" %> <%= form.label :email, style: "display: inline" %> @<%=@domain.domain%>
<%= form.text_field :email %> <%= form.text_field :email %>
</div> </div>

View File

@ -5,6 +5,6 @@
<br> <br>
<div> <div>
<%= link_to "Show this credential", @credential %> | <%#= link_to "Show this credential", @credential %> |
<%= link_to "Back to credentials", credentials_path %> <%#= link_to "Back to credentials", credentials_path %>
</div> </div>

View File

@ -1,5 +1,3 @@
<p style="color: green"><%= notice %></p>
<h1>Domains</h1> <h1>Domains</h1>
<div id="domains"> <div id="domains">

View File

@ -1,4 +1,3 @@
<p style="color: green"><%= notice %></p>
<h1><%= @domain.domain %></h1> <h1><%= @domain.domain %></h1>
<div> <div>
@ -9,7 +8,8 @@
<ul> <ul>
<li><%= link_to "Add #{@domain.domain} email address", new_domain_credential_path(@domain) %> <li><%= link_to "Add #{@domain.domain} email address", new_domain_credential_path(@domain) %>
<% @domain.credentials.each do |credential| %> <% @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 %> <% end %>
</ul> </ul>

View File

@ -9,5 +9,5 @@ Rails.application.routes.draw do
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Defines the root path route ("/") # Defines the root path route ("/")
root "home#index" root "domains#index"
end end

View File

@ -39,4 +39,14 @@ class VirtualTest < ActiveSupport::TestCase
assert !@v.save assert !@v.save
end 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 end