Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class MessagesController < ApplicationController
before_action :set_message, only: %i[ edit update destroy ]

# GET /messages or /messages.json
def index
query = params[:q]
Expand All @@ -25,62 +23,4 @@ def show
@message = Message.find_by(list_id: list.id, list_seq: params[:list_seq])
end
end

# GET /messages/new
def new
@message = Message.new
end

# GET /messages/1/edit
def edit
end

# POST /messages or /messages.json
def create
@message = Message.new(message_params)

respond_to do |format|
if @message.save
format.html { redirect_to message_url(@message), notice: "Message was successfully created." }
format.json { render :show, status: :created, location: @message }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @message.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /messages/1 or /messages/1.json
def update
respond_to do |format|
if @message.update(message_params)
format.html { redirect_to message_url(@message), notice: "Message was successfully updated." }
format.json { render :show, status: :ok, location: @message }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @message.errors, status: :unprocessable_entity }
end
end
end

# DELETE /messages/1 or /messages/1.json
def destroy
@message.destroy!

respond_to do |format|
format.html { redirect_to messages_url, notice: "Message was successfully destroyed." }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_message
@message = Message.find(params[:id])
end

# Only allow a list of trusted parameters through.
def message_params
params.require(:message).permit(:subject, :from, :body)
end
end
2 changes: 0 additions & 2 deletions app/views/messages/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@
</li>
<% end %>
</ul>

<%= link_to "New message", new_message_path %>
31 changes: 0 additions & 31 deletions test/controllers/messages_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,4 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest
get messages_url
assert_response :success
end

test "should get new" do
get new_message_url
assert_response :success
end

test "should create message" do
assert_difference("Message.count") do
post messages_url, params: { message: { body: @message.body, from: @message.from, subject: @message.subject } }
end

assert_redirected_to message_url(Message.last)
end

test "should get edit" do
get edit_message_url(@message)
assert_response :success
end

test "should update message" do
patch message_url(@message), params: { message: { body: @message.body, from: @message.from, subject: @message.subject } }
assert_redirected_to message_url(@message)
end

test "should destroy message" do
assert_difference("Message.count", -1) do
delete message_url(@message)
end

assert_redirected_to messages_url
end
end
32 changes: 0 additions & 32 deletions test/system/messages_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,4 @@ class MessagesTest < ApplicationSystemTestCase
assert_selector "h1", text: "Messages"
end

test "should create message" do
visit messages_url
click_on "New message"

fill_in "Body", with: @message.body
fill_in "From", with: @message.from
fill_in "Subject", with: @message.subject
click_on "Create Message"

assert_text "Message was successfully created"
click_on "Back"
end

test "should update Message" do
visit message_url(@message)
click_on "Edit this message", match: :first

fill_in "Body", with: @message.body
fill_in "From", with: @message.from
fill_in "Subject", with: @message.subject
click_on "Update Message"

assert_text "Message was successfully updated"
click_on "Back"
end

test "should destroy Message" do
visit message_url(@message)
click_on "Destroy this message", match: :first

assert_text "Message was successfully destroyed"
end
end