Sha256: 003bb166c347c6ede3227408ab20293554e8876f46173c4008577194e9fd6542

Contents?: true

Size: 1.95 KB

Versions: 21

Compression:

Stored size: 1.95 KB

Contents

require "spec_helper"

describe AwesomeTranslations::MovalsController do
  let!(:handler_translation) { create :handler_translation, translation_key: translation_key, dir: Rails.root.join("config", "locales", "some", "right", "path") }
  let!(:translation_key) { create :translation_key, key: "some.key" }
  let!(:translation_value) { create :translation_value, translation_key: translation_key, file_path: Rails.root.join("config", "locales", "some", "wrong", "path", "en.yml") }

  let!(:handler_translation_right_path) { create :handler_translation, translation_key: translation_key_right_path, dir: "/some/path" }
  let!(:translation_key_right_path) { create :translation_key, key: "some.right.key" }
  let!(:translation_value_right_path) { create :translation_value, translation_key: translation_key_right_path, file_path: "/some/path/en.yml" }

  before do
    dir_path = File.dirname(translation_value.file_path)
    FileUtils.mkdir_p(dir_path) unless File.exist?(dir_path)

    translation_yaml = {
      "en" => {
        "some" => {
          "key" => "translation"
        }
      }
    }

    File.open(translation_value.file_path, "w") do |fp|
      fp.write(YAML.dump(translation_yaml))
    end
  end

  describe "#index" do
    it "renders the page and shows the correct results" do
      visit movals_path

      expect(page).to have_http_status(:success)
      expect(current_path).to eq movals_path

      find("input[type=checkbox][value='#{handler_translation.id}']") # Expect to find

      expect do
        find("input[type=checkbox][value='#{handler_translation_right_path.id}']")
      end.to raise_error(Capybara::ElementNotFound)
    end
  end

  describe "#create" do
    it "moves the checked translations to the right path" do
      visit movals_path

      find("input[type=submit]").click
      translation_value.reload

      expect(translation_value.file_path).to eq Rails.root.join("config", "locales", "some", "right", "path", "en.yml").to_s
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
awesome_translations-0.0.53 spec/features/movals_spec.rb
awesome_translations-0.0.52 spec/features/movals_spec.rb
awesome_translations-0.0.51 spec/features/movals_spec.rb
awesome_translations-0.0.50 spec/features/movals_spec.rb
awesome_translations-0.0.49 spec/features/movals_spec.rb
awesome_translations-0.0.48 spec/features/movals_spec.rb
awesome_translations-0.0.47 spec/features/movals_spec.rb
awesome_translations-0.0.46 spec/features/movals_spec.rb
awesome_translations-0.0.45 spec/features/movals_spec.rb
awesome_translations-0.0.44 spec/features/movals_spec.rb
awesome_translations-0.0.43 spec/features/movals_spec.rb
awesome_translations-0.0.42 spec/features/movals_spec.rb
awesome_translations-0.0.41 spec/features/movals_spec.rb
awesome_translations-0.0.40 spec/features/movals_spec.rb
awesome_translations-0.0.39 spec/features/movals_spec.rb
awesome_translations-0.0.38 spec/features/movals_spec.rb
awesome_translations-0.0.37 spec/features/movals_spec.rb
awesome_translations-0.0.36 spec/features/movals_spec.rb
awesome_translations-0.0.35 spec/features/movals_spec.rb
awesome_translations-0.0.34 spec/features/movals_spec.rb