Skip to content

Commit

Permalink
Merge pull request #1587 from CruGlobal/GT-2182-remove-old-publish-me…
Browse files Browse the repository at this point in the history
…thod

GT-2182, remove old method of publishing
  • Loading branch information
frett authored May 17, 2024
2 parents 469c92b + ba7a168 commit 237f863
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 54 deletions.
16 changes: 0 additions & 16 deletions app/controllers/drafts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ def create
head :no_content
end

def update
edit
end

def destroy
load_translation.destroy!
head :no_content
Expand All @@ -45,18 +41,6 @@ def language_id
data_attrs[:language_id]
end

def edit
translation = load_translation

# Note that this endpoint isn't used for anything other than publishing to s3. Eventually once the new client switches
# to the new way of publishing, we'll delete this file
# see: https://jira.cru.org/browse/GT-2182
do_publishing = data_attrs[:is_published]

translation.push_published_to_s3 if do_publishing
render json: translation, status: :ok
end

def load_translation
Translation.find(params[:id])
end
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
resources :translated_attributes, path: "translated-attributes", only: [:create, :update, :destroy]
post "translations/publish", to: "resources#publish_translation"
end
resources :drafts
resources :drafts, only: [:index, :show, :create, :destroy]
resources :translations, only: [:index, :show]
resources :pages, only: [:create, :update, :show]
resources :tips, only: [:create, :update]
Expand Down
37 changes: 0 additions & 37 deletions spec/acceptance/drafts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,43 +123,6 @@
end
end

put "drafts/:id" do
let(:id) { "3" }
let(:attrs) { {is_published: true} }

requires_authorization

context "all phrases are translated" do
before do
translation = Translation.find(3)
allow(Translation).to receive(:find).with(id).and_return(translation)
allow(translation).to receive(:push_published_to_s3)

do_request data: {type: :translation, attributes: attrs}
end

it "update draft" do
expect(JSON.parse(response_body)["data"]).not_to be_nil
end

it "returns OK", document: false do
expect(status).to be(200)
end
end

context "all phrases are not translated" do
it "returns conflict", document: false do
translation = Translation.find(1)
allow(translation).to receive(:push_published_to_s3).and_raise(Error::TextNotFoundError, "Translated phrase not found.")
allow(Translation).to receive(:find).with(id).and_return(translation)

do_request data: {type: :translation, attributes: attrs}

expect(status).to be(409)
end
end
end

delete "drafts/:id" do
let(:id) { 1 }
let(:translation) { double }
Expand Down

0 comments on commit 237f863

Please sign in to comment.